Conversation
Don't heap allocate to lowercase strings. This only works for ASCII characters but since we're only matching against ASCII strings it doesn't matter what happens to non-ASCII characters. This turns out to be slightly faster as well: benchmark old ns/op new ns/op delta BenchmarkAgentSurfer-8 3605 3371 -6.49% BenchmarkAgentSurferReuse-8 3591 3333 -7.18% BenchmarkEvalSystem-8 2076 2046 -1.45% BenchmarkEvalBrowserName-8 1257 1261 +0.32% BenchmarkEvalBrowserVersion-8 69.3 69.5 +0.29% BenchmarkEvalDevice-8 756 750 -0.79% BenchmarkParseChromeMac-8 1237 1140 -7.84% BenchmarkParseChromeWin-8 1149 1037 -9.75% BenchmarkParseChromeAndroid-8 3753 3540 -5.68% BenchmarkParseSafariMac-8 2012 1888 -6.16% BenchmarkParseSafariiPad-8 2031 1892 -6.84%
|
@ryanslade any reason this isn't merged yet? |
|
Thanks for this, however I'd rather not introduce the use of the Also, there is a chance that a user agent contains non ascii characters which this change ignores. |
|
Yes the user agent might contains non ascii characters but those aren't used in any of the matching so it wouldn't matter if they are lower cased or not. What's the reason for not wanting to introduce the use of the |
|
@erikdubbelboer It seems like you can use |
|
This is about the string that is lowercased. |
Don't heap allocate to lowercase strings.
This only works for ASCII characters but since we're only matching against ASCII strings it doesn't matter what happens to non-ASCII characters.
This turns out to be slightly faster as well: