Commit 02b9d467 authored by alexander.shalamov's avatar alexander.shalamov Committed by Commit bot

bindings: Pass dictionaries to callback methods by const reference

Before this CL, strings and container types were passed to callback
method by const reference. Dictionary types should also be passed
by const ref to avoid unnecessary copying.

BUG=557590

Review URL: https://codereview.chromium.org/1455883003

Cr-Commit-Position: refs/heads/master@{#360549}
parent a96dc167
......@@ -63,7 +63,8 @@ def cpp_type(idl_type):
return 'void'
# Callbacks use raw pointers, so raw_type=True
raw_cpp_type = idl_type.cpp_type_args(raw_type=True)
if raw_cpp_type.startswith(('Vector', 'HeapVector', 'WillBeHeapVector')):
# Pass containers and dictionaries to callback method by const reference rather than by value
if raw_cpp_type.startswith(('Vector', 'HeapVector', 'WillBeHeapVector')) or idl_type.is_dictionary:
return 'const %s&' % raw_cpp_type
return raw_cpp_type
......
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