From a3b4ad06b992bd418a1d34bfb271c09fd9bedf11 Mon Sep 17 00:00:00 2001 From: murphy Date: Tue, 21 Mar 2006 14:46:34 +0000 Subject: =?UTF-8?q?CodeRay::Duo=20added=20for=20cool=20caching!=20bench/ca?= =?UTF-8?q?ching.rb=20added=20t=C2=B4for=20demonstrating=20this.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HTML Encoder: creates unwrapped output by default (still problems with that.) Numerizing changed (doesn't try to prevent nesting errors) Speedup: "::String" is faster. --- lib/coderay/scanner.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/coderay/scanner.rb') diff --git a/lib/coderay/scanner.rb b/lib/coderay/scanner.rb index 33bcb09..5ff07a0 100644 --- a/lib/coderay/scanner.rb +++ b/lib/coderay/scanner.rb @@ -115,6 +115,16 @@ module CodeRay # More mnemonic accessor name for the input string. alias code string + def reset + super + reset_tokens + end + + def string= str + super + reset_tokens + end + # Scans the code and returns all tokens in a Tokens object. def tokenize options = {} options = @options.merge({}) #options @@ -158,6 +168,11 @@ module CodeRay "#{self.class}#scan_tokens not implemented." end + def reset_tokens + @tokens.clear + @cached_tokens = nil + end + # Scanner error with additional status information def raise_inspect msg, tokens, ambit = 30 raise ScanError, <<-EOE % [ -- cgit v1.2.1