Commit 92159b3b authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

IDL compiler: Stop creating copies of primitive objects.

A lot of copies of 'str' are just waste of memory in the
current design/implementation, so this patch stops creating
copies of primitive objects.

Bug: 839389
Change-Id: I9873986dab0a13340768badfc119100c88eea733
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774004Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691200}
parent 7df854c5
......@@ -26,12 +26,11 @@ def make_copy(obj, memo=None):
if copy is not None:
return copy
cls = type(obj)
if isinstance(obj, (bool, int, long, float, complex, basestring)):
# Subclasses of simple builtin types are expected to have a copy
# constructor.
return cls.__new__(cls, obj)
# Do not create a copy of a primitive (and its subclasses) object.
return obj
cls = type(obj)
if isinstance(obj, (list, tuple, set, frozenset)):
return cls(map(lambda x: make_copy(x, memo), obj))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment