-
-
Save wycats/49678fe276a990289133 to your computer and use it in GitHub Desktop.
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
require "bundler/setup" | |
require "allocation_counter" | |
string = "hello" | |
scanner = StringScanner.new(string) | |
AllocationCounter.simple do | |
scanner.skip(/hello/) | |
end | |
# it (1 times) | |
# ============ | |
# allocated: 1 | |
# string: 1 | |
AllocationCounter.simple do | |
scanner.skip(/hello/u) | |
end | |
# it (1 times) | |
# ============ | |
# allocated: GOOD WORK! NO ALLOCATIONS :+1: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment