File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
gapic/templates/%namespace/%name_%version/%sub/services/%service Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -283,7 +283,12 @@ class {{ service.async_client_name }}:
283283 request = {{ method.input.ident }}({% if method .input .ident .package != method .ident .package %}{% for f in method .flattened_fields .values () %} {{ f.name }}={{ f.name }}, {% endfor %}{% endif %} )
284284 {% endif %} {# Cross-package req and flattened fields #}
285285 {% else %}
286- request = {{ method.input.ident }}(request)
286+ # Minor optimization to avoid making a copy if the user passes
287+ # in a {{ method.input.ident }}.
288+ # There's no risk of modifying the input as we've already verified
289+ # there are no flattened fields.
290+ if not isinstance(request, {{ method.input.ident }}):
291+ request = {{ method.input.ident }}(request)
287292 {% endif %} {# different request package #}
288293
289294 {# Vanilla python protobuf wrapper types cannot _set_ repeated fields #}
You can’t perform that action at this time.
0 commit comments