Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance issue for regexp in Reporting.kt #4550

Merged
merged 1 commit into from Jan 31, 2022
Merged

Conversation

schalkms
Copy link
Member

A regexp object is compiled into an internal data structure during initialization.
This could to a potential performance impact, if the Regex() constructor is called multiple times for the same pattern.
Since the private function truncatedMessage() could be called a lot, this PR fixes this potential performance issue.

Because of the overhead of object instantiation and regular expression compilation, reusing the initialized object is the recommended way.

A regexp object is compiled into an internal data structure during initialization.
This could to a potential performance impact, if the `Regex()` constructor is called multiple times for the same pattern.
Since the private function `truncatedMessage()` could be called a lot, this PR fixes this potential performance issue.

Because of the overhead of object instantiation and regular expression compilation, reusing the initialized object is the recommended way.
@codecov
Copy link

codecov bot commented Jan 31, 2022

Codecov Report

Merging #4550 (3f54be6) into main (0b36ff0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##               main    #4550   +/-   ##
=========================================
  Coverage     84.42%   84.42%           
  Complexity     3323     3323           
=========================================
  Files           479      479           
  Lines         11139    11140    +1     
  Branches       2039     2039           
=========================================
+ Hits           9404     9405    +1     
  Misses          700      700           
  Partials       1035     1035           
Impacted Files Coverage Δ
...tlab/arturbosch/detekt/core/reporting/Reporting.kt 94.00% <100.00%> (+0.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b36ff0...3f54be6. Read the comment docs.

@BraisGabin BraisGabin merged commit fb1b604 into main Jan 31, 2022
@BraisGabin BraisGabin deleted the schalkms-regexp branch January 31, 2022 22:25
@cortinico cortinico added this to the 1.20.0 milestone Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants