Minor refactoring

git-svn-id: http://pugixml.googlecode.com/svn/trunk@689 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
arseny.kapoulkine 2010-08-29 15:47:01 +00:00
parent 0dd0b4c496
commit b75c5360f3

View File

@ -169,7 +169,7 @@ namespace pugi
{ {
static xml_memory_page* construct(void* memory) static xml_memory_page* construct(void* memory)
{ {
if (!memory) return 0; if (!memory) return 0; //$ redundant, left for performance
xml_memory_page* result = static_cast<xml_memory_page*>(memory); xml_memory_page* result = static_cast<xml_memory_page*>(memory);
@ -204,7 +204,7 @@ namespace pugi
struct xml_allocator struct xml_allocator
{ {
xml_allocator(xml_memory_page* root): _root(root), _busy_size(root ? root->busy_size : 0) xml_allocator(xml_memory_page* root): _root(root), _busy_size(root->busy_size)
{ {
} }
@ -1163,9 +1163,7 @@ namespace
convert_buffer_utf32(out_buffer, out_length, contents, size, opt_true()); convert_buffer_utf32(out_buffer, out_length, contents, size, opt_true());
} }
// invalid encoding combination (this can't happen) assert(!"Invalid encoding");
assert(false);
return false; return false;
} }
#else #else
@ -1238,9 +1236,7 @@ namespace
convert_buffer_utf32(out_buffer, out_length, contents, size, opt_true()); convert_buffer_utf32(out_buffer, out_length, contents, size, opt_true());
} }
// invalid encoding combination (this can't happen) assert(!"Invalid encoding");
assert(false);
return false; return false;
} }
#endif #endif
@ -2429,9 +2425,7 @@ namespace
return static_cast<size_t>(end - dest) * sizeof(uint32_t); return static_cast<size_t>(end - dest) * sizeof(uint32_t);
} }
// invalid encoding combination (this can't happen) assert(!"Invalid encoding");
assert(false);
return 0; return 0;
} }
#else #else
@ -2483,9 +2477,7 @@ namespace
return static_cast<size_t>(end - dest) * sizeof(uint32_t); return static_cast<size_t>(end - dest) * sizeof(uint32_t);
} }
// invalid encoding combination (this can't happen) assert(!"Invalid encoding");
assert(false);
return 0; return 0;
} }
#endif #endif
@ -2676,8 +2668,7 @@ namespace
break; break;
default: default:
// invalid encoding (this should not happen) assert(!"Invalid encoding");
assert(false);
} }
} }
@ -2868,7 +2859,7 @@ namespace
break; break;
default: default:
assert(false); assert(!"Invalid node type");
} }
} }
@ -2942,7 +2933,7 @@ namespace
} }
default: default:
assert(false); assert(!"Invalid node type");
} }
} }
@ -5432,7 +5423,7 @@ namespace
break; break;
default: default:
assert(false); assert(!"Invalid variable type");
} }
} }
@ -5754,10 +5745,18 @@ namespace pugi
switch (_type) switch (_type)
{ {
case type_sorted: return *_begin; case type_sorted:
case type_sorted_reverse: return *(_end - 1); return *_begin;
case type_unsorted: return *pstd::min_element(_begin, _end, document_order_comparator());
default: return xpath_node(); case type_sorted_reverse:
return *(_end - 1);
case type_unsorted:
return *pstd::min_element(_begin, _end, document_order_comparator());
default:
assert(!"Invalid node set type");
return xpath_node();
} }
} }
@ -8332,7 +8331,7 @@ namespace pugi
return static_cast<const xpath_variable_boolean*>(this)->name; return static_cast<const xpath_variable_boolean*>(this)->name;
default: default:
assert(false); assert(!"Invalid variable type");
return 0; return 0;
} }
} }