Skip to content

Conversation

@kamil-tekiela
Copy link

This is micro-optimisation for the hot path. For the average case, it is 1.5x-2x faster. For the common case, this is 3.6x-5x faster. In the worst case, it is 1.3x faster.

@sebastianbergmann sebastianbergmann added the type/performance Issues related to resource consumption (time and memory) label Jan 21, 2026
@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.01%. Comparing base (1aba907) to head (1514e00).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #6475   +/-   ##
=========================================
  Coverage     96.01%   96.01%           
- Complexity     7352     7353    +1     
=========================================
  Files           798      798           
  Lines         22627    22629    +2     
=========================================
+ Hits          21726    21728    +2     
  Misses          901      901           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kamil-tekiela
Copy link
Author

I do not know why Coding Guidelines failed. I executed the cs-fixer as suggested by the guidelines and it didn't find anything on my machine. I might be doing it wrong. Is it because array_key_exists is not imported?

@staabm
Copy link
Contributor

staabm commented Jan 21, 2026

locally I get

   1) /Users/m.staab/dvl/phpunit/src/Util/Color.php
      ---------- begin diff ----------
--- /Users/m.staab/dvl/phpunit/src/Util/Color.php
+++ /Users/m.staab/dvl/phpunit/src/Util/Color.php
@@ -11,6 +11,7 @@
 
 use const DIRECTORY_SEPARATOR;
 use const PHP_EOL;
+use function array_key_exists;
 use function array_map;
 use function array_walk;
 use function count;
@@ -91,8 +92,10 @@
         }
 
         $styles = [];
+
         foreach (explode(',', $color) as $code) {
             $code = trim($code);
+
             if (array_key_exists($code, self::ANSI_CODES)) {
                 $styles[] = self::ANSI_CODES[$code];
             }

      ----------- end diff -----------

for tools/php-cs-fixer fix --diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/performance Issues related to resource consumption (time and memory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants