mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1438700, part 2 - Deduplicate XPT strings. r=glandium
Various strings, like nsISupports, appear many times in XPT data. This patch adds a cache so we don't write the same string multiple times. MozReview-Commit-ID: 6buBrXwHqQz --HG-- extra : rebase_source : 54dea83a9134710c5600828ab68ef3f935f46afd
This commit is contained in:
parent
b553286f4a
commit
a106e111fe
@ -577,10 +577,14 @@ class CachedStringWriter(object):
|
||||
def __init__(self, file, data_pool_offset):
|
||||
self.file = file
|
||||
self.data_pool_offset = data_pool_offset
|
||||
self.names = {}
|
||||
|
||||
def write(self, s):
|
||||
if s:
|
||||
if s in self.names:
|
||||
return self.names[s]
|
||||
offset = self.file.tell() - self.data_pool_offset + 1
|
||||
self.names[s] = offset
|
||||
self.file.write(s + "\x00")
|
||||
return offset
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user