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
$ macruby -wIlib bench/bench.rb ruby null 10 | |
unknown: warning: global variable `$CODERAY_DEBUG' not initialized | |
user system total real | |
unknown: warning: instance variable @plugin_hash not initialized | |
CodeRay unknown: warning: instance variable @plugin_hash not initialized | |
unknown: warning: instance variable @file_extension not initialized | |
unknown: warning: instance variable @encoding not initialized | |
4.130000 0.200000 4.330000 ( 4.009760) | |
2.49 KB/s (10.0 KB) 63.23 KTok/s |
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
diff --git a/lib/strscan.rb b/lib/strscan.rb | |
index 3908bfb..b2ac46c 100644 | |
--- a/lib/strscan.rb | |
+++ b/lib/strscan.rb | |
@@ -161,7 +161,7 @@ class StringScanner | |
end | |
def rest | |
- @string[pos..-1] | |
+ @string.substring(@pos, rest_size) |
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
# create | |
def Bench.run | |
string = '' | |
5_000_000.times do | |
StringScanner.new string | |
string << '.' | |
end | |
end | |
# create2 |
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
ruby -rstrscan -e 's = StringScanner.new(a = ""); a << "test"; p s.scan(/test/)' | |
"test" | |
rbx -rstrscan -e 's = StringScanner.new(a = ""); a << "test"; p s.scan(/test/)' | |
nil |
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
def Bench.run | |
a = '' | |
1_000_000.times do | |
StringScanner.new a | |
a << '.' | |
end | |
end |
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
diff --git a/lib/strscan.rb b/lib/strscan.rb | |
index c7c2b97..78dcb41 100644 | |
--- a/lib/strscan.rb | |
+++ b/lib/strscan.rb | |
@@ -46,7 +46,7 @@ class StringScanner | |
end | |
def concat(str) | |
- @string << str | |
+ @string << StringValue(str) |
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
File "/Users/murphy/.rvm/src/rbx-head/vm/external_libs/llvm/bindings/ocaml/llvm/Release/llvm.ml", line 1, characters 0-1: | |
Error: Assembler error, input left in file /var/folders/Dz/DzvRDA80GLCU+bKFJvJQN++++TI/-Tmp-/camlasm6f2b11.s | |
make[3]: *** [/Users/murphy/.rvm/src/rbx-head/vm/external_libs/llvm/bindings/ocaml/llvm/Release/llvm.cmx] Error 2 | |
make[3]: Leaving directory `/Users/murphy/.rvm/src/rbx-head/vm/external_libs/llvm/bindings/ocaml/llvm' | |
make[2]: *** [all] Error 1 | |
make[2]: Leaving directory `/Users/murphy/.rvm/src/rbx-head/vm/external_libs/llvm/bindings/ocaml' | |
make[1]: *** [ocaml/.makeall] Error 2 | |
make[1]: Leaving directory `/Users/murphy/.rvm/src/rbx-head/vm/external_libs/llvm/bindings' | |
make: *** [all] Error 1 | |
rake aborted! |
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
@@ -140,7 +140,7 @@ module ActiveSupport | |
private | |
def thread_local_key | |
- @thread_local_key ||= "#{self.class.name.underscore}_local_cache_#{self.object_id}".gsub("/", "_").to_sym | |
+ @thread_local_key ||= "#{self.class.name.underscore}_local_cache_#{object_id}".gsub(/[\/-]/, '_').to_sym | |
end | |
def local_cache |
NewerOlder