Changeset 26 for trunk/Classes/serialization/tokenizer.hpp
- Timestamp:
- 2010-05-28 07:39:52 (2 years ago)
- File:
-
- 1 edited
-
trunk/Classes/serialization/tokenizer.hpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Classes/serialization/tokenizer.hpp
r4 r26 23 23 #include <string> 24 24 25 #define TOKENIZER_BUFFER_SIZE 50 * 1024 * 1024 26 25 27 class config; 26 28 … … 31 33 leading_spaces(), 32 34 value() 33 {} 35 { 36 reset(); 37 } 34 38 35 39 enum token_type { … … 53 57 value.clear(); 54 58 leading_spaces.clear(); 59 /* 60 value_ptr = 0; 61 value_size = 0; 62 leading_spaces_ptr = 0; 63 leading_spaces_size = 0; 64 */ 55 65 } 56 66 57 67 std::string leading_spaces; 58 68 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 */ 59 77 }; 60 78 … … 64 82 public: 65 83 tokenizer(std::istream& in); 66 ~tokenizer() {}84 ~tokenizer(); 67 85 68 86 const token& next_token(); // KP: moved to tokenizer.cpp … … 71 89 { 72 90 if(token_.value == "_") 91 //if(token_.value_ptr && token_.value_ptr[0] == '_') 73 92 token_.type = token::token_type('_'); 74 93 } … … 115 134 do { 116 135 if (LIKELY(in_.good())) 136 //if (curPos < numChars-1) 117 137 { 118 138 current_ = in_.get(); 139 //current_ = (unsigned char) in_buffer[curPos++]; 119 140 } 120 141 else … … 123 144 return; 124 145 } 125 }while (UNLIKELY(current_ == '\r')); 146 } while (UNLIKELY(current_ == '\r')); 147 126 148 #if 0 127 149 // @todo: disabled untill campaign server is fixed … … 146 168 { 147 169 return in_.peek(); 170 //return in_buffer[curPos]; 148 171 } 149 172 … … 153 176 return c == ' ' || c == '\t'; 154 177 } 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 160 180 void skip_comment(); 161 181 … … 167 187 #endif 168 188 std::istream& in_; 189 190 /* 191 // KP: added for much faster tokenizing 192 char *in_buffer; 193 int curPos; 194 int numChars; 195 */ 169 196 }; 170 197
Note: See TracChangeset
for help on using the changeset viewer.