grpc-js-core: remove extra map() calls in fromHttp2Headers()

The extra map() calls added an extra loop over the arrays
just to trim() a string. This commit moves the trim() into
the forEach() and drops the map().
This commit is contained in:
cjihrig 2018-08-25 12:23:08 -04:00
parent b64ed1c18e
commit 2c75b64071
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
1 changed files with 4 additions and 4 deletions

View File

@ -205,9 +205,9 @@ export class Metadata {
result.add(key, Buffer.from(value, 'base64'));
});
} else if (values !== undefined) {
values.split(',')
.map(v => v.trim())
.forEach(v => result.add(key, Buffer.from(v, 'base64')));
values.split(',').forEach(v => {
result.add(key, Buffer.from(v.trim(), 'base64'));
});
}
} else {
if (Array.isArray(values)) {
@ -215,7 +215,7 @@ export class Metadata {
result.add(key, value);
});
} else if (values !== undefined) {
values.split(',').map(v => v.trim()).forEach(v => result.add(key, v));
values.split(',').forEach(v => result.add(key, v.trim()));
}
}
});