Trevoke/SGFParser — Issue #17: Speed Increases
Author: Tempus
Created: 2011-12-07 08:45:02+00:00
State: open

The SGF parser is slllloooow.

Specifically...

### SGF::Parser#next_character:
!@stream.eof? && @stream.sysread(1) is really slow. The stream methods are poor choices because they don’t get cached at all. You’d find exponential improvements in speed by reading the whole thing to a buffer at once, and then just slicing it or iterating over it.

### SGF::Parser#parse_property
is really slow, due to the while loops in parse_comment, parse_multi_property and parse_generic_property. Please use built in string methods instead, they are much faster than your pure ruby implementation. Since you should now be reading to a buffer, you don’t need to go over ever character individually - expect huge speed ups.

### SGF::Parser#still_inside_node?
steam methods AND while loop. lucky this doesn’t get called much.

Generally, reworking the parser to work with built-ins on a buffered read should do two things:
1) immense speed ups
2) no more issues with ]