Repository navigation
Conversation
Split the string into its fields then do specific tests on each (with numeric comparison for numeric fields) instead of doing a whole-string string regex match each time. The second field and the first part of the third field are constants (and if they don't match, something is badly unsupported), the most salient detail is the second part of the third field, and the first field only has one or two known values (depending on the second part of the third field). That means it is inefficient to keep restarting the regex engine at the beginning, where it usually matches, only to usually fail towards the end. Instead, first do string equality tests for the known bad second and first-part-of-third fields. Then iterate through the numeric (!string) known second-part-of-third to quickly check this highly variable detail. Only then do a test for first field if we get that far (thanks to lazy evaluation of conditionals). Finally, complete the numeric comparison for known kernel subversions.
Member
|
Seems like a reasonable idea to me. |
Contributor
|
So... any idea about those merge conflicts? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split the string into its fields then do specific tests on each (with
numeric comparison for numeric fields) instead of doing a whole-string
string regex match each time.
The second field and the first part of the third field are constants
(and if they don't match, something is badly unsupported), the most
salient detail is the second part of the third field, and the first
field only has one or two known values (depending on the second part
of the third field). That means it is inefficient to keep restarting
the regex engine at the beginning, where it usually matches, only to
usually fail towards the end.
Instead, first do string equality tests for the known bad second and
first-part-of-third fields. Then iterate through the numeric (!string)
known second-part-of-third to quickly check this highly variable
detail. Only then do a test for first field if we get that far (thanks
to lazy evaluation of conditionals). Finally, complete the numeric
comparison for known kernel subversions.