summaryrefslogtreecommitdiff
path: root/binaryurp/source/lessoperators.cxx
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2013-05-08 17:26:08 +0000
committerTor Lillqvist <tml@iki.fi>2013-05-28 09:27:01 +0300
commit08bb8fca4144608237418d64b1479840c408256f (patch)
treed9ccc0b7af4e6fa8020573e863c8e83dc3915c89 /binaryurp/source/lessoperators.cxx
parentda1dea9ae24fd4b17c54646f158c617a098291aa (diff)
#i122208# replace the binaryurp cache for improved C++ compatibility
Failing to instantiatie incomplete types like the Map::iterator in binaryurp Cache's Entry members is allowed by the C++ standard. The rewrite makes it more compliant with other C++ compilers/STLs. And interesting alternative would be to use boost's multi_index_container. git-svn-id: http://svn.apache.org/repos/asf/openoffice/branches/rejuvenate01@1480367 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'binaryurp/source/lessoperators.cxx')
-rw-r--r--binaryurp/source/lessoperators.cxx44
1 files changed, 34 insertions, 10 deletions
diff --git a/binaryurp/source/lessoperators.cxx b/binaryurp/source/lessoperators.cxx
index b0031e716815..55f3a49c2340 100644
--- a/binaryurp/source/lessoperators.cxx
+++ b/binaryurp/source/lessoperators.cxx
@@ -32,14 +32,38 @@
namespace com { namespace sun { namespace star { namespace uno {
-bool operator <(TypeDescription const & left, TypeDescription const & right) {
- assert(left.is() && right.is());
- typelib_TypeClass tc1 = left.get()->eTypeClass;
- typelib_TypeClass tc2 = right.get()->eTypeClass;
- return tc1 < tc2 ||
- (tc1 == tc2 &&
- (OUString(left.get()->pTypeName) <
- OUString(right.get()->pTypeName)));
+bool operator<( const TypeDescription& rLeft, const TypeDescription& rRight) {
+ assert( rLeft.is() && rRight.is());
+ const typelib_TypeDescription& rA = *rLeft.get();
+ const typelib_TypeDescription& rB = *rRight.get();
+ if( rA.eTypeClass != rA.eTypeClass)
+ return (rA.eTypeClass < rB.eTypeClass);
+ const sal_Int32 nCmp = rtl_ustr_compare_WithLength(
+ rA.pTypeName->buffer, rA.pTypeName->length,
+ rB.pTypeName->buffer, rB.pTypeName->length);
+ return (nCmp < 0);
+}
+
+bool TypeDescEqual::operator()( const TypeDescription& rLeft, const TypeDescription& rRight) const
+{
+ assert( rLeft.is() && rRight.is());
+ const typelib_TypeDescription& rA = *rLeft.get();
+ const typelib_TypeDescription& rB = *rRight.get();
+ if( rA.eTypeClass != rB.eTypeClass)
+ return false;
+ const sal_Int32 nCmp = rtl_ustr_compare_WithLength(
+ rA.pTypeName->buffer, rA.pTypeName->length,
+ rB.pTypeName->buffer, rB.pTypeName->length);
+ return (nCmp == 0);
+}
+
+sal_Int32 TypeDescHash::operator()( const TypeDescription& rTD) const
+{
+ assert( rTD.is());
+ const typelib_TypeDescription& rA = *rTD.get();
+ sal_Int32 h = rtl_ustr_hashCode_WithLength( rA.pTypeName->buffer, rA.pTypeName->length);
+ h ^= static_cast<sal_Int32>(rA.eTypeClass);
+ return h;
}
} } } }
@@ -47,8 +71,8 @@ bool operator <(TypeDescription const & left, TypeDescription const & right) {
namespace rtl {
bool operator <(ByteSequence const & left, ByteSequence const & right) {
- for (sal_Int32 i = 0; i != std::min(left.getLength(), right.getLength());
- ++i)
+ const sal_Int32 nLen = std::min( left.getLength(), right.getLength());
+ for( sal_Int32 i = 0; i < nLen; ++i )
{
if (left[i] < right[i]) {
return true;