From 25d154bbf94157f0bdf71a71964409857634c570 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 7 Mar 2014 16:19:31 +0100 Subject: Use getTypes instead of getImplementationId as cache key so we can hopefully deprecate getImplementationId and make all implementations return an empty sequence. Change-Id: I161b5fce727541ea2c8303b5d228dbc4939a55b6 --- stoc/source/inspect/introspection.cxx | 50 +++++++++++++++-------------------- 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'stoc') diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index b2e84caf8900..09dc11ba9e54 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -1483,12 +1483,23 @@ struct ClassKeyLess { struct TypeKey { TypeKey( css::uno::Reference const & theProperties, - css::uno::Sequence const & theId): - properties(theProperties), id(theId) - {} + css::uno::Sequence const & theTypes): + properties(theProperties) + { + //TODO: Could even sort the types lexicographically first, to increase + // the chance of matches between different implementations' getTypes(), + // but the old scheme of using getImplementationId() would have missed + // those matches, too: + OUStringBuffer b; + for (sal_Int32 i = 0; i != theTypes.getLength(); ++i) { + b.append(theTypes[i].getTypeName()); + b.append('*'); // arbitrary delimiter not used by type grammar + } + types = b.makeStringAndClear(); + } css::uno::Reference properties; - css::uno::Sequence id; + OUString types; }; struct TypeKeyLess { @@ -1499,21 +1510,7 @@ struct TypeKeyLess { if (key1.properties.get() > key2.properties.get()) { return false; } - if (key1.id.getLength() < key2.id.getLength()) { - return true; - } - if (key1.id.getLength() > key2.id.getLength()) { - return false; - } - for (sal_Int32 i = 0; i != key1.id.getLength(); ++i) { - if (key1.id[i] < key2.id[i]) { - return true; - } - if (key1.id[i] > key2.id[i]) { - return false; - } - } - return false; + return key1.types < key2.types; } }; @@ -1704,16 +1701,13 @@ css::uno::Reference Implementation::inspect( } if (xTypeProvider.is()) { - css::uno::Sequence id(xTypeProvider->getImplementationId()); - if (id.hasElements()) { - TypeKey key(xPropSetInfo, id); - pAccess = typeCache_.find(key); - if (pAccess.is()) { - return new ImplIntrospectionAccess(aToInspectObj, pAccess); - } - pAccess = new IntrospectionAccessStatic_Impl(reflection_); - typeCache_.insert(key, pAccess); + TypeKey key(xPropSetInfo, xTypeProvider->getTypes()); + pAccess = typeCache_.find(key); + if (pAccess.is()) { + return new ImplIntrospectionAccess(aToInspectObj, pAccess); } + pAccess = new IntrospectionAccessStatic_Impl(reflection_); + typeCache_.insert(key, pAccess); } else if (xImplClass.is()) { ClassKey key(xPropSetInfo, xImplClass, SupportedClassSeq); pAccess = classCache_.find(key); -- cgit v1.2.3