-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use char instead of byte indexes for length, substr, index, and match (…
…#83) I've done this as a runtime config setting, Config.Bytes, and the default is character mode. So this is a backwards-incompatible change, but I think it's 1) warranted given GoAWK tries to conform to POSIX, and 2) won't break most scripts, even ones that use non-ASCII, unless they use constant indexes for substr() on non-ASCII strings. This definitely affects performance, as some operations that were O(1) are now O(N) in the length of the string. Here are the results for the relevant functions (though obviously it'll depend on the string len): name old time/op new time/op delta BuiltinLength-8 615ns ± 3% 4179ns ± 3% +579.68% (p=0.008 n=5+5) BuiltinSubstr-8 985ns ± 0% 3874ns ± 0% +293.12% (p=0.008 n=5+5) BuiltinIndex-8 1.24µs ± 0% 4.70µs ± 6% +278.85% (p=0.008 n=5+5) BuiltinMatch-8 2.90µs ± 0% 3.30µs ± 3% +13.70% (p=0.008 n=5+5) [Geo mean] 2.35µs 3.98µs +69.30% Fixes #35
- Loading branch information
Showing
6 changed files
with
354 additions
and
226 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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