summaryrefslogtreecommitdiff
path: root/lib/coderay/tokens.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-09-19 18:26:49 +0000
committermurphy <murphy@rubychan.de>2010-09-19 18:26:49 +0000
commit5a0f656ed67c055ac30b66c5f31c5b13c924710f (patch)
tree77d921f8991f8fde63bff36b16d2c4fc3852c619 /lib/coderay/tokens.rb
parentd1cc4333fd57b7265975a9f62d220e4fa6aeb670 (diff)
downloadcoderay-5a0f656ed67c055ac30b66c5f31c5b13c924710f.tar.gz
Speedup for Rubinius: Use Array#<< instead of #push (see #251).
Diffstat (limited to 'lib/coderay/tokens.rb')
-rw-r--r--lib/coderay/tokens.rb34
1 files changed, 26 insertions, 8 deletions
diff --git a/lib/coderay/tokens.rb b/lib/coderay/tokens.rb
index 93d2dbd..84e67c5 100644
--- a/lib/coderay/tokens.rb
+++ b/lib/coderay/tokens.rb
@@ -282,7 +282,7 @@ module CodeRay
def count
size / 2
end
-
+
# Include this module to give an object an #undump
# method.
#
@@ -293,7 +293,7 @@ module CodeRay
Tokens.load self
end
end
-
+
# Undump the object using Marshal.load, then
# unzip it using GZip.gunzip.
#
@@ -303,12 +303,30 @@ module CodeRay
dump = GZip.gunzip dump
@dump = Marshal.load dump
end
-
- alias text_token push
- def begin_group kind; push :begin_group, kind end
- def end_group kind; push :end_group, kind end
- def begin_line kind; push :begin_line, kind end
- def end_line kind; push :end_line, kind end
+
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE['rbx']
+ def text_token text, kind
+ self << text << kind
+ end
+ def begin_group kind
+ self << :begin_group << kind
+ end
+ def end_group kind
+ self << :end_group << kind
+ end
+ def begin_line kind
+ self << :begin_line << kind
+ end
+ def end_line kind
+ self << :end_line << kind
+ end
+ else
+ alias text_token push
+ def begin_group kind; push :begin_group, kind end
+ def end_group kind; push :end_group, kind end
+ def begin_line kind; push :begin_line, kind end
+ def end_line kind; push :end_line, kind end
+ end
alias tokens concat
end