Ignore:
Timestamp:
2010-05-28 07:39:52 (2 years ago)
Author:
kpoole
Message:

Episode 5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Classes/serialization/tokenizer.hpp

    r4 r26  
    2323#include <string> 
    2424 
     25#define TOKENIZER_BUFFER_SIZE   50 * 1024 * 1024 
     26 
    2527class config; 
    2628 
     
    3133        leading_spaces(), 
    3234        value() 
    33         {} 
     35        { 
     36            reset(); 
     37        } 
    3438 
    3539    enum token_type { 
     
    5357        value.clear(); 
    5458        leading_spaces.clear(); 
     59        /* 
     60        value_ptr = 0; 
     61        value_size = 0; 
     62        leading_spaces_ptr = 0; 
     63        leading_spaces_size = 0; 
     64         */ 
    5565    } 
    5666 
    5767    std::string leading_spaces; 
    5868    std::string value; 
     69     
     70    /* 
     71    // KP: creating std::strings all the time was a huge performance hit 
     72    const char *leading_spaces_ptr; 
     73    int leading_spaces_size; 
     74    const char *value_ptr; 
     75    int value_size; 
     76    */ 
    5977}; 
    6078 
     
    6482    public: 
    6583        tokenizer(std::istream& in); 
    66         ~tokenizer() {} 
     84        ~tokenizer(); 
    6785 
    6886        const token& next_token();  // KP: moved to tokenizer.cpp 
     
    7189        { 
    7290            if(token_.value == "_") 
     91            //if(token_.value_ptr && token_.value_ptr[0] == '_') 
    7392                token_.type = token::token_type('_'); 
    7493        } 
     
    115134            do { 
    116135                if (LIKELY(in_.good())) 
     136                //if (curPos < numChars-1) 
    117137                { 
    118138                    current_ = in_.get(); 
     139                    //current_ = (unsigned char) in_buffer[curPos++]; 
    119140                } 
    120141                else 
     
    123144                    return; 
    124145                } 
    125             }while (UNLIKELY(current_ == '\r')); 
     146            } while (UNLIKELY(current_ == '\r')); 
     147                         
    126148#if 0 
    127149            // @todo: disabled untill campaign server is fixed 
     
    146168        { 
    147169            return in_.peek(); 
     170            //return in_buffer[curPos]; 
    148171        } 
    149172 
     
    153176            return c == ' ' || c == '\t'; 
    154177        } 
    155         inline bool is_alnum(const int c) const 
    156         { 
    157             return (c >= 'a' && c <= 'z') 
    158                 || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_'; 
    159         } 
     178    /*inline*/ bool is_alnum(const int c) const; 
     179         
    160180        void skip_comment(); 
    161181 
     
    167187#endif 
    168188        std::istream& in_; 
     189     
     190        /* 
     191        // KP: added for much faster tokenizing 
     192        char *in_buffer; 
     193        int curPos; 
     194        int numChars; 
     195         */ 
    169196}; 
    170197 
Note: See TracChangeset for help on using the changeset viewer.