summaryrefslogtreecommitdiff
path: root/registry/tools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-02-03 10:40:46 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-02-03 10:44:23 +0100
commit02b9e755f71227d91fc93bf940699da6772c5b33 (patch)
tree074db7c0cc610a65d8ebe782fab340051643bdf4 /registry/tools
parent4783eea7269010910879ed3584b229d9492a2ddc (diff)
reg2bin: Shrink output by reusing common strings
...all the "Offset of Idx-Name" in the data format can likely be further shrunk by getting rid of the newly added level of indirection again. Change-Id: I322f4869a4d6f2e63802406f998e22beea30db41
Diffstat (limited to 'registry/tools')
-rw-r--r--registry/tools/reg2bin.cxx16
1 files changed, 13 insertions, 3 deletions
diff --git a/registry/tools/reg2bin.cxx b/registry/tools/reg2bin.cxx
index 7e5001e05d26..d10ad2a13b9c 100644
--- a/registry/tools/reg2bin.cxx
+++ b/registry/tools/reg2bin.cxx
@@ -974,9 +974,19 @@ sal_uInt64 writeNameNul(osl::File & file, rtl::OUString const & name) {
}
void writeNameLen(osl::File & file, rtl::OUString const & name) {
- rtl::OString ascii(toAscii(name));
- write32(file, ascii.getLength());
- write(file, ascii.getStr(), ascii.getLength());
+ static std::map< rtl::OUString, sal_uInt64 > reuse;
+ std::map< rtl::OUString, sal_uInt64 >::iterator i(reuse.find(name));
+ if (i == reuse.end()) {
+ reuse.insert(std::make_pair(name, getOffset(file)));
+ rtl::OString ascii(toAscii(name));
+ assert(
+ (static_cast< sal_uInt64 >(ascii.getLength()) & 0x80000000) == 0);
+ write32(
+ file, static_cast< sal_uInt64 >(ascii.getLength()) | 0x80000000);
+ write(file, ascii.getStr(), ascii.getLength());
+ } else {
+ write32(file, i->second);
+ }
}
void writeType(osl::File & file, Item const & item, bool flag = false) {