diff options
| author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2014-11-19 22:44:08 -0800 | 
|---|---|---|
| committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2014-11-19 22:44:08 -0800 | 
| commit | b8437664a9d6b5697f09611b96951c005ab2554a (patch) | |
| tree | 61d2d82f8a5744dae5dc59ea52f5c8d750525ca5 /src | |
| parent | 6d048deba8dfb8ccb8122b6c905b08b75f5090bf (diff) | |
XPath: Minor string operation refactoring
Extract end of string to rend and add comments to translate_table.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pugixml.cpp | 11 | 
1 files changed, 8 insertions, 3 deletions
| diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 194c77d..c15ed6b 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -7435,6 +7435,7 @@ PUGI__NS_BEGIN  			if (fc >= 128 || tc >= 128)  				return 0; +			// code=128 means "skip character"  			if (!table[fc])  				table[fc] = static_cast<unsigned char>(tc ? tc : 128); @@ -7469,6 +7470,8 @@ PUGI__NS_BEGIN  			{  				unsigned char code = table[index]; +				// code=128 means "skip character" (table size is 128 so 128 can be a special value) +				// this code skips these characters without extra branches  				*write = static_cast<char_t>(code);  				write += 1 - (code >> 7);  			} @@ -9525,9 +9528,10 @@ PUGI__NS_BEGIN  				const char_t* pos = find_substring(s.c_str(), p.c_str());  				if (!pos) return xpath_string(); -				const char_t* result = pos + p.length(); +				const char_t* rbegin = pos + p.length(); +				const char_t* rend = s.c_str() + s.length(); -				return s.uses_heap() ? xpath_string::from_heap(result, s.c_str() + s.length(), stack.result) : xpath_string::from_const(result); +				return s.uses_heap() ? xpath_string::from_heap(rbegin, rend, stack.result) : xpath_string::from_const(rbegin);  			}  			case ast_func_substring_2: @@ -9548,8 +9552,9 @@ PUGI__NS_BEGIN  				assert(1 <= pos && pos <= s_length + 1);  				const char_t* rbegin = s.c_str() + (pos - 1); +				const char_t* rend = s.c_str() + s.length(); -				return s.uses_heap() ? xpath_string::from_heap(rbegin, s.c_str() + s.length(), stack.result) : xpath_string::from_const(rbegin); +				return s.uses_heap() ? xpath_string::from_heap(rbegin, rend, stack.result) : xpath_string::from_const(rbegin);  			}  			case ast_func_substring_3: | 
