public
Description: A Ruby-based parsing DSL based on parsing expression grammars.
Homepage: http://treetop.rubyforge.org
Clone URL: git://github.com/nathansobo/treetop.git
Memoization works for the nil objects that are now returned for parse 
failures.

The hash lookup explicitly asks if a key exists rather than checking for 
nil.
pivotal (author)
Mon Dec 10 09:35:15 -0800 2007
commit  beaefb2901bd1ec9cb5ebdef2b77c330ea22b9d1
tree    7f053015978b428463fb6ca2e3ac92f0b5e7330f
parent  493653ba15d6ef1f37f5a45b3db2382fae18d91c
...
32
33
34
35
36
37
 
 
 
38
39
40
...
32
33
34
 
 
 
35
36
37
38
39
40
0
@@ -32,9 +32,9 @@ module Treetop
0
       end
0
       
0
       def generate_cache_lookup(builder)
0
- builder.assign 'cached', "node_cache[:#{name}][index]"
0
- builder.if_ 'cached' do
0
- builder << '@index = cached.interval.end'
0
+ builder.if_ "node_cache[:#{name}].has_key?(index)" do
0
+ builder.assign 'cached', "node_cache[:#{name}][index]"
0
+ builder << '@index = cached.interval.end if cached'
0
           builder << 'return cached'
0
         end
0
       end

Comments

    No one has commented yet.