diff options
| author | Markus Roberts <Markus@reality.com> | 2010-04-29 14:20:44 -0700 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | 088c80148d1fa082ac6f79023739bc268d096bc0 (patch) | |
| tree | 6caf72cc73206ef52de412eaa5865615d5bd4ff7 /lib/puppet/parser | |
| parent | cd06b877cd97edb26551d9c30c399d666603e586 (diff) | |
| download | puppet-088c80148d1fa082ac6f79023739bc268d096bc0.tar.gz puppet-088c80148d1fa082ac6f79023739bc268d096bc0.tar.xz puppet-088c80148d1fa082ac6f79023739bc268d096bc0.zip | |
Fix for #3558 -- source file reading speedup
It's about 10x faster to read the whole file than to read each line and
concatenate them (actually, it's O(n) vs. O(n^2), so the exact speedup
depends on the file size).
Diffstat (limited to 'lib/puppet/parser')
| -rw-r--r-- | lib/puppet/parser/lexer.rb | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index 2a1f88e44..f13a85f35 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -286,16 +286,10 @@ class Puppet::Parser::Lexer return array end - # this is probably pretty damned inefficient... - # it'd be nice not to have to load the whole file first... def file=(file) @file = file @line = 1 - File.open(file) { |of| - str = "" - of.each { |line| str += line } - @scanner = StringScanner.new(str) - } + @scanner = StringScanner.new(File.read(file)) end def shift_token |
