File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -363,7 +363,7 @@ Optional<std::string> find_container_id(std::istream& source) {
363363
364364 std::string line;
365365
366- // First, iterate using the simple substring match .
366+ // Look for Docker container IDs in the basic format: `docker-<uuid>.scope` .
367367 while (std::getline (source, line)) {
368368 // Example:
369369 // `0::/system.slice/docker-abcdef0123456789abcdef0123456789.scope`
@@ -383,12 +383,13 @@ Optional<std::string> find_container_id(std::istream& source) {
383383 source.clear ();
384384 source.seekg (0 );
385385
386- // If no match is found, iterate using the regex match.
386+ // Perform a second pass using a regular expression for matching container IDs in a Fargate environment.
387+ // This two-step approach is used because STL `regex` is relatively slow, so we avoid using it unless necessary.
387388 while (std::getline (source, line)) {
388389 // Example:
389390 // `0::/system.slice/docker-abcdef0123456789abcdef0123456789.scope`
390391 std::smatch match;
391- if (std::regex_match (line, match, path_reg)) {
392+ if (std::regex_match (line, match, path_reg) && match. size () == 2 ) {
392393 assert (match.ready ());
393394 assert (match.size () == 2 );
394395
You can’t perform that action at this time.
0 commit comments