fs: fix permanent deoptimizations
PR-URL: https://github.com/nodejs/node/pull/12456 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
e9c02c6762
commit
e8a429075f
12
lib/fs.js
12
lib/fs.js
@ -82,8 +82,8 @@ function getOptions(options, defaultOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function copyObject(source) {
|
function copyObject(source) {
|
||||||
const target = {};
|
var target = {};
|
||||||
for (const key in source)
|
for (var key in source)
|
||||||
target[key] = source[key];
|
target[key] = source[key];
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ fs.existsSync = function(path) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fs.readFile = function(path, options, callback) {
|
fs.readFile = function(path, options, callback) {
|
||||||
callback = maybeCallback(arguments[arguments.length - 1]);
|
callback = maybeCallback(callback || options);
|
||||||
options = getOptions(options, { flag: 'r' });
|
options = getOptions(options, { flag: 'r' });
|
||||||
|
|
||||||
if (handleError((path = getPathFromURL(path)), callback))
|
if (handleError((path = getPathFromURL(path)), callback))
|
||||||
@ -1216,9 +1216,7 @@ fs.futimesSync = function(fd, atime, mtime) {
|
|||||||
binding.futimes(fd, atime, mtime);
|
binding.futimes(fd, atime, mtime);
|
||||||
};
|
};
|
||||||
|
|
||||||
function writeAll(fd, isUserFd, buffer, offset, length, position, callback_) {
|
function writeAll(fd, isUserFd, buffer, offset, length, position, callback) {
|
||||||
var callback = maybeCallback(arguments[arguments.length - 1]);
|
|
||||||
|
|
||||||
// write(fd, buffer, offset, length, position, callback)
|
// write(fd, buffer, offset, length, position, callback)
|
||||||
fs.write(fd, buffer, offset, length, position, function(writeErr, written) {
|
fs.write(fd, buffer, offset, length, position, function(writeErr, written) {
|
||||||
if (writeErr) {
|
if (writeErr) {
|
||||||
@ -1249,7 +1247,7 @@ function writeAll(fd, isUserFd, buffer, offset, length, position, callback_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFile = function(path, data, options, callback) {
|
fs.writeFile = function(path, data, options, callback) {
|
||||||
callback = maybeCallback(arguments[arguments.length - 1]);
|
callback = maybeCallback(callback || options);
|
||||||
options = getOptions(options, { encoding: 'utf8', mode: 0o666, flag: 'w' });
|
options = getOptions(options, { encoding: 'utf8', mode: 0o666, flag: 'w' });
|
||||||
const flag = options.flag || 'w';
|
const flag = options.flag || 'w';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user