[SuperSize] Rework SymbolGroup unique Symbols iteration.
DeltaSymbolGroup.CountUniqueSymbols() sums separate unique leaf symbol counts in "before" and "after". Previously this was done via temporary SymbolGroups and using their CountUniqueSymbols(). As a memory optimization, both temporary SymbolGroups were given Symbol iterators at construction. However, the |_symbols| member become single- use as a result. This violates the immutability property of the object, and causes problem as we plan to process |_symbols| in upcoming work to add multi-container support. A short fix is to convert input and make |_symbols| as a list, but this is opaque, and undoes the optimization above. This CL makes the following changes instead: * Assert that SymbolGroup() is given list at construction. * Replace SymbolGroups.IterUniqueSymbols() with a static generator SymbolGroups.IterUnique() that takes an input iterator. * All callers undergo minor change. * Callers of {Delta}SymbolGroups.CountUniqueSymbol() are unchanged. * Update DeltaSymbolGroup.CountUniqueSymbols() to use the new interface, without needing temporary SymbolGroups. Optimization is kept. Bug: 1040645 Change-Id: I32c3867fe006a078f9a6ddcf764349b360120e9a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2204304 Commit-Queue: Samuel Huang <huangs@chromium.org> Reviewed-by:Andrew Grieve <agrieve@chromium.org> Cr-Commit-Position: refs/heads/master@{#769997}
Showing
Please register or sign in to comment