Skip to content

Commit

Permalink
fixup! fs: add a fast-path for readFileSync utf-8
Browse files Browse the repository at this point in the history
Backport-PR-URL: nodejs#48658
  • Loading branch information
anonrig authored and H4ad committed Dec 2, 2023
1 parent fdcc2da commit cc7b552
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ function readFileSync(path, options) {

// TODO(@anonrig): Do not handle file descriptor ownership for now.
if (!isUserFd && (options.encoding === 'utf8' || options.encoding === 'utf-8')) {
return readFileSyncUtf8(getValidatedPath(path), stringToFlags(options.flag));
path = getValidatedPath(path);
return readFileSyncUtf8(pathModule.toNamespacedPath(path), stringToFlags(options.flag));
}

const fd = isUserFd ? path : fs.openSync(path, options.flag, 0o666);
Expand Down

0 comments on commit cc7b552

Please sign in to comment.