mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
Use .to_string() directly for reduction in build size
Went from 3,325,128b to 3,287,744b for accessapproval1 by using .to_string() directly, under --release config.
This commit is contained in:
@@ -1242,13 +1242,14 @@ def size_to_bytes(size):
|
||||
|
||||
|
||||
def string_impl(p):
|
||||
"""Returns a function which will convert instances of p to a string"""
|
||||
return {
|
||||
"google-duration": "::client::serde::duration::to_string",
|
||||
"byte": "::client::serde::urlsafe_base64::to_string",
|
||||
"google-datetime": "::client::serde::datetime_to_string",
|
||||
"date-time": "::client::serde::datetime_to_string",
|
||||
"google-fieldmask": "(|x: &client::FieldMask| x.to_string())"
|
||||
}.get(p.get("format"), "(|x: &dyn std::fmt::Display| x.to_string())")
|
||||
"google-duration": lambda x: f"::client::serde::duration::to_string(&{x})",
|
||||
"byte": lambda x: f"::client::serde::urlsafe_base64::to_string(&{x})",
|
||||
"google-datetime": lambda x: f"::client::serde::datetime_to_string(&{x})",
|
||||
"date-time": lambda x: f"::client::serde::datetime_to_string(&{x})",
|
||||
"google-fieldmask": lambda x: f"{x}.to_string()"
|
||||
}.get(p.get("format"), lambda x: f"{x}.to_string()")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -556,15 +556,15 @@ match result {
|
||||
% if p.get('repeated', False):
|
||||
if ${pname}.len() > 0 {
|
||||
for f in ${pname}.iter() {
|
||||
params.push(("${p.name}", ${to_string_impl}(f)));
|
||||
params.push(("${p.name}", ${to_string_impl("f")}));
|
||||
}
|
||||
}
|
||||
% elif not is_required_property(p):
|
||||
if let Some(value) = ${pname}.as_ref() {
|
||||
params.push(("${p.name}", ${to_string_impl}(value)));
|
||||
params.push(("${p.name}", ${to_string_impl("value")}));
|
||||
}
|
||||
% else:
|
||||
params.push(("${p.name}", ${to_string_impl}(&${pname})));
|
||||
params.push(("${p.name}", ${to_string_impl(pname)}));
|
||||
% endif
|
||||
% endfor
|
||||
## Additional params - may not overlap with optional params
|
||||
|
||||
Reference in New Issue
Block a user