Skip to content

Instantly share code, notes, and snippets.

@@ -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
@rubychan
rubychan / gist:835606
Created February 20, 2011 02:02
Rubinius compile error
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!
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)
def Bench.run
a = ''
1_000_000.times do
StringScanner.new a
a << '.'
end
end
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
# create
def Bench.run
string = ''
5_000_000.times do
StringScanner.new string
string << '.'
end
end
# create2
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)
@rubychan
rubychan / gist:859282
Created March 7, 2011 21:31
MacRuby vs. CodeRay benchmarks
$ 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
Index: lib/coderay/scanners/ruby/patterns.rb
===================================================================
--- lib/coderay/scanners/ruby/patterns.rb (revision 706)
+++ lib/coderay/scanners/ruby/patterns.rb (working copy)
@@ -33,18 +33,7 @@
add(RESERVED_WORDS, :reserved).
add(PREDEFINED_CONSTANTS, :pre_constant)
- if /\w/u === '∑'
- # MRI 1.8.6, 1.8.7
Benchmarking with CodeRay 0.9.7:
real 0m4.007s
user 0m3.933s
sys 0m0.068s
Benchmarking with latest CodeRay:
real 0m2.090s
user 0m2.056s