cppuhelper/source/bootstrap.cxx| 60 ---
stoc/source/simpleregistry/simpleregistry.cxx | 98 +
stoc/source/simpleregistry/textualservices.cxx | 11 ++
stoc/source/simpleregistry/textualservices.hxx |3
4 files changed, 146 insertions(+), 26 deletions(-)
New commits:
commit 4baeaf5484fb23f8265ab693bb7d2a36fbfef9c5
Author: Michael Meeks michael.me...@suse.com
Date: Fri Apr 13 15:25:23 2012 +0200
stoc: accelerate opening of multiple XML .rdb files in a directory
Instead of nesting these, we aggregate them into a single non-nested
registry, which saves lots of CPU at startup, sadly we can only do
that for the new-style XML registries, so we have to sniff files,
nevertheless this is still far faster. The merged xml files also
break the XSimpleRegistry::getURL() method - but it appears not
to get called.
Signed-off-by: Stephan Bergmann sberg...@redhat.com
diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx
index 7d8ef9c..7ead585 100644
--- a/cppuhelper/source/bootstrap.cxx
+++ b/cppuhelper/source/bootstrap.cxx
@@ -263,16 +263,17 @@ Reference registry::XSimpleRegistry readRdbDirectory(
url),
css::uno::Reference css::uno::XInterface ());
}
-for (css::uno::Reference css::registry::XSimpleRegistry last(
- lastRegistry);;)
+std::vectorrtl::OUString aURLs;
+css::uno::Reference css::registry::XSimpleRegistry last(lastRegistry);
+for (;;)
{
osl::DirectoryItem i;
-switch (dir.getNextItem(i, SAL_MAX_UINT32)) {
-case osl::FileBase::E_None:
+osl::FileBase::RC eResult;
+eResult = dir.getNextItem(i, SAL_MAX_UINT32);
+if (eResult == osl::FileBase::E_NOENT)
break;
-case osl::FileBase::E_NOENT:
-return last;
-default:
+if (eResult != osl::FileBase::E_None)
+{
throw css::uno::RuntimeException(
(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(cannot iterate directory )) +
@@ -296,12 +297,49 @@ Reference registry::XSimpleRegistry readRdbDirectory(
if (aName.toChar() == '.' || aName.endsWithAsciiL(~, 1))
continue;
-if (stat.getFileType() != osl::FileStatus::Directory) { //TODO:
symlinks
-last = readRdbFile(
-stat.getFileURL(), fatalErrors, last, simpleRegistryFactory,
-nestedRegistryFactory);
+if (stat.getFileType() != osl::FileStatus::Directory) //TODO: symlinks
+aURLs.push_back(stat.getFileURL());
+}
+
+size_t nXML = 0;
+for (std::vectorrtl::OUString::iterator it = aURLs.begin(); it !=
aURLs.end(); it++)
+{
+// Read / sniff the nasty files ...
+osl::File aIn( *it );
+if (aIn.open(osl_File_OpenFlag_Read) != osl::FileBase::E_None)
+continue;
+
+sal_uInt64 nRead = 0;
+char buffer[6];
+bool bIsXML = aIn.read(buffer, 6, nRead) == osl::FileBase::E_None
+ nRead == 6 !strncmp(buffer, ?xml , 6);
+aIn.close();
+if (!bIsXML)
+{
+OSL_TRACE (OSL_LOG_PREFIX rdb '%s' is a legacy format\n,
+ rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8
).getStr());
+break;
+}
+nXML++;
+}
+if (nXML == aURLs.size())
+{
+OSL_TRACE (OSL_LOG_PREFIX no legacy rdbs in directory '%s'\n,
+ rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8
).getStr());
+// read whole directory...
+last = readRdbFile( url, fatalErrors, last,
+simpleRegistryFactory, nestedRegistryFactory);
+}
+else
+{
+for (std::vectorrtl::OUString::iterator it = aURLs.begin(); it !=
aURLs.end(); it++)
+{
+// Read / sniff the nasty files ...
+last = readRdbFile(*it, fatalErrors, last,
+ simpleRegistryFactory, nestedRegistryFactory);
}
}
+return last;
}
Reference registry::XSimpleRegistry nestRegistries(
diff --git a/stoc/source/simpleregistry/simpleregistry.cxx
b/stoc/source/simpleregistry/simpleregistry.cxx
index 085b73a..1c1e983 100644
--- a/stoc/source/simpleregistry/simpleregistry.cxx
+++ b/stoc/source/simpleregistry/simpleregistry.cxx
@@ -48,6 +48,7 @@
#include cppuhelper/implbase2.hxx
#include cppuhelper/weak.hxx
#include osl/mutex.hxx
+#include osl/file.hxx
#include registry/registry.hxx
#include registry/regtype.h
#include rtl/ref.hxx
@@ -84,6 +85,12 @@ public:
private:
virtual rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException);
+virtual void SAL_CALL openRdb(
+rtl::OUString const rURL, sal_Bool bReadOnly, sal_Bool bCreate)
+throw (
+css::registry::InvalidRegistryException,
+