Changes between Version 1 and Version 2 of Ticket #1995, comment 4


Ignore:
Timestamp:
Jun 26, 2013, 3:37:35 AM (11 years ago)
Author:
Jorma Rebane

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1995, comment 4

    v1 v2  
    1 Some notes on patches "CParser_replaced.patch" and "Hotkey.patch"
    2 
    3 1) CParser was a horrible freak of a regex parser. It left a horrible memory footprint and slowed the game down during load times. After replacing it with something much much simpler, the game startup and exit time was noticeably faster (alloc/dealloc overhead probably).
    4 
    5 How SStrTok works:
    6    A string tokenizer doesn't own the string or memory you give it, so make sure the resource exists while you parse.
    7 {{{
    8     std::string input = " toggle = 'Alt+F' = else ";
    9     std::string key, value;
    10     SStrTok tokenizer(input);
    11     SStrTok token;
    12     if(tokenizer.next(token, '=')) // split tokens at '='
    13     {   // if a token was availablee (no EOS)
    14         token.trim().toString(key); // trim whitespace, then tostr
    15         // key == "toggle"
    16     }
    17     if(tokenizer.next(token, '='))
    18     {
    19         token.trim(" '").toString(value); // trim spaces and '
    20         // value == "Alt+F"
    21     }
    22 }}}
    23 
    24 
    25 
    26 2) Hotkey patch is a fix that was pretty easy to make - it makes hotkey triggers a lot faster and memory efficient than they used to be. No real functionality changed inside 0 A.D. - only the stuff under the hood got changed.
    27 
    28 
    29 
    30 
    31 Notes on these two patches: They kind of rely on each other, since "Hotkey.cpp" also uses SStrTok tokenizer for parsing hotkey combos.
     1CParser fix finished. Check ticket: #2005