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 Nov 21, 2021
1 parent e1c2ef5 commit 243f171
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/core/core/src/PackagerRunner.js
Expand Up @@ -639,10 +639,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 243f171

Please sign in to comment.