Skip to content

Commit

Permalink
fewer string-Buffer conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Dec 7, 2021
1 parent 7fef00f commit 3a817e2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/core/core/src/PackagerRunner.js
Expand Up @@ -648,10 +648,11 @@ export default class PackagerRunner {
);
hash = h.finish();
} else if (typeof contents === 'string') {
size = Buffer.byteLength(contents);
hash = hashString(contents);
let buffer = Buffer.from(contents);
size = buffer.byteLength;
hash = hashBuffer(buffer);
hashReferences = contents.match(HASH_REF_REGEX) ?? [];
await this.options.cache.setBlob(cacheKeys.content, contents);
await this.options.cache.setBlob(cacheKeys.content, buffer);
} else {
size = contents.length;
hash = hashBuffer(contents);
Expand Down

0 comments on commit 3a817e2

Please sign in to comment.