hanmyohtwe / waitzar

Automatically exported from code.google.com/p/waitzar
Other
0 stars 0 forks source link

Parsing config files for errors should be done separately, if there's an error. #99

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The spirit_json library's docs say that the version of parsing which checks
for errors is about 3x slower than the one that just returns an error code. 

Since good users don't have config errors, and those with config errors
don't care about performance (because the program won't start) then let's
re-write the config parser to use the fast method, check the return value,
and then re-run the slower method if there was a problem. 

This needs to be tested; last time I tried to check the return value, I
somehow just skipped all errors.

Original issue reported on code.google.com by seth.h...@gmail.com on 4 Feb 2010 at 3:06

GoogleCodeExporter commented 8 years ago
On a related note, our parser "ignores" three tokens:
  space_p | comment_p('#') | L"\uFEFF"

The first two are somewhat intensive, as they match items of an unknown length, 
and
only in a certain context. The last one is required as Notepad loves adding 
UTF-8
BOMs for no reason.

We could fairly easily parse out all whitespace, comments, and BOMs when we 
first
read the config file into a string. This isn't so terribly costly, and it would
probably help to speed up the recursive descent parser. I'm adding it to this 
bug; we
should definitely do both when possible. (I.e., soon.)

Now, all I need is a mis-typed config file to test this all on....

Original comment by seth.h...@gmail.com on 4 Mar 2010 at 9:08

GoogleCodeExporter commented 8 years ago
All is done. Speed is back to where it used to be in Debug mode (because 
vectors are
so horribly slow in Debug mode). Will check in Release mode later.

Original comment by seth.h...@gmail.com on 5 Mar 2010 at 12:53