avoid references for single char strings

This commit is contained in:
Tobias Koppers 2020-12-13 23:31:51 +01:00
parent c194abeb65
commit f3bd8eda5b
1 changed files with 3 additions and 3 deletions

View File

@ -452,8 +452,8 @@ class ObjectMiddleware extends SerializerMiddleware {
addReferenceable(item);
} else if (typeof item === "string") {
if (item !== "") {
// empty strings are shorter when not emitting a reference (this saves 1 byte per empty string)
if (item.length > 1) {
// short strings are shorter when not emitting a reference (this saves 1 byte per empty string)
addReferenceable(item);
}
@ -637,7 +637,7 @@ class ObjectMiddleware extends SerializerMiddleware {
}
}
} else if (typeof item === "string") {
if (item !== "") {
if (item.length > 1) {
addReferenceable(item);
}