One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The "assign" optimization removes over 10% of the execution time.
| 399 | // "assign" optimization removes over 10% of the execution time. |
| 400 | // |
| 401 | const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) |
| 402 | { |
| 403 | // Oddly, not supported on some comilers, |
| 404 | //name->clear(); |
| 405 | // So use this: |
| 406 | *name = ""; |
| 407 | assert( p ); |
| 408 | |
| 409 | // Names start with letters or underscores. |
| 410 | // Of course, in unicode, tinyxml has no idea what a letter *is*. The |
| 411 | // algorithm is generous. |
| 412 | // |
| 413 | // After that, they can be letters, underscores, numbers, |
| 414 | // hyphens, or colons. (Colons are valid ony for namespaces, |
| 415 | // but tinyxml can't tell namespaces from names.) |
| 416 | if ( p && *p |
| 417 | && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) |
| 418 | { |
| 419 | const char* start = p; |
| 420 | while( p && *p |
| 421 | && ( IsAlphaNum( (unsigned char ) *p, encoding ) |
| 422 | || *p == '_' |
| 423 | || *p == '-' |
| 424 | || *p == '.' |
| 425 | || *p == ':' ) ) |
| 426 | { |
| 427 | //(*name) += *p; // expensive |
| 428 | ++p; |
| 429 | } |
| 430 | if ( p-start > 0 ) { |
| 431 | name->assign( start, p-start ); |
| 432 | } |
| 433 | return p; |
| 434 | } |
| 435 | return 0; |
| 436 | } |
| 437 | |
| 438 | const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) |
| 439 | { |
nothing calls this directly
no outgoing calls
no test coverage detected