-
Notifications
You must be signed in to change notification settings - Fork 243
Closed
Description
Is your feature request related to a problem? Please describe.
- JavaScript SDK team would like to reduce bundle size of JavaScript SDK v3 by removing unnecessary variables
- One such way is to remove some local redundant variables like
wrappedItemfrom ser-deser functions (code)- First part of this is using reusable function like
getArrayIfSingleItem(commit) - The second part of it is to pass output pass call value returned by
getArrayIfSingleItemto another function (experimental commit)
- First part of this is using reusable function like
Describe the solution you'd like
- CodeWriter exposes a function (say
format) which returns formatted string. - This String can later be passed to
Existing write function: https://github.com/awslabs/smithy/blob/34d51e3f7f9c351ed0867a816e082ba3ac56cc4c/smithy-utils/src/main/java/software/amazon/smithy/utils/CodeWriter.java#L925-L945
This function can be as follows:
public final CodeWriter write(Object content, Object... args) {
String value = format(content, args);
String[] lines = value.split(newlineRegexQuoted, -1);
// Indent lines and strip excessive newlines.
for (String line : lines) {
currentState.writeLine(line + newline);
}
return this;
}
public final String format(Object content, Object... args) {
return formatter.format(content, currentState.indentText, this, args);
}Describe alternatives you've considered
- Using
String.formatinstead which might surface bugs in future - Get around by writing complex CodeGen code using just the
writemethod
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels