• Samuel Huang's avatar
    [Supersize] Simplify _AddNmAliases() new symbols insertion. · 8a5b85bd
    Samuel Huang authored
    _AddNmAliases() updates raw_symbols by adding symbols that have the
    same address as existing ones, but with different names. For example,
    let raw_symbols be:
      [A1, X, B1, B2, B3, Y, C1, C2],
    and suppose X can be replaced with [X1, X2, X3] and Y with [Y1, Y2].
    The old code modifies raw_symbols in place by adding gaps first:
      [A1, X, B1, B2, B3, Y, C1, C2, ?, ?, ?],
    then move elements to gaps (! are overwritable, including Y):
      [A1, X, B1, B2, B3, !, !, !, ?,  C1 ,C2],
    then writes the new symbols in reverse order:
      [A1, X, B1, B2, B3, !, !, Y2, Y1, C1 ,C2].
    Repeating (X writable):
      [A1, !, !, !, B1, B2, B3, Y2, Y1, C1 ,C2],
      [A1, X3, X2, X1, B1, B2, B3, Y2, Y1, C1 ,C2].
    
    The code works but is rather complex, and it reverses the order of
    new symbols inserted. This CL simplifies the code by allocating a new
    array, and insert new symbols in order (of whatever |names_by_address|
    returns). The obtained result for the example would now be:
      [A1, X1, X2, X3, B1, B2, B3, Y1, Y2, C1 ,C2].
    
    Note the change of new elements' order. As a result, this CL affects
    patch content, and requires change in test data. The computation time
    of _AddMnAliases() is negligible (~0.1s).
    
    Change-Id: I5bfb7cceb9e1ebbdf493cea55c92144581721b40
    Reviewed-on: https://chromium-review.googlesource.com/922986Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
    Reviewed-by: default avataragrieve <agrieve@chromium.org>
    Commit-Queue: Samuel Huang <huangs@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#537479}
    8a5b85bd
SymbolGroupMethods.golden 16.1 KB