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 Sep 17, 2023
1 parent 05d468a commit fccbb41
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 @@ -473,7 +473,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 fccbb41

Please sign in to comment.