Skip to content

Commit

Permalink
fs: fix permanent deoptimizations
Browse files Browse the repository at this point in the history
PR-URL: #12456
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
mscdex authored and evanlucas committed May 3, 2017
1 parent 7d0adc6 commit 84484b7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function getOptions(options, defaultOptions) {
}

function copyObject(source) {
const target = {};
for (const key in source)
var target = {};
for (var key in source)
target[key] = source[key];
return target;
}
Expand Down Expand Up @@ -273,7 +273,7 @@ fs.existsSync = function(path) {
};

fs.readFile = function(path, options, callback) {
callback = maybeCallback(arguments[arguments.length - 1]);
callback = maybeCallback(callback || options);
options = getOptions(options, { flag: 'r' });

if (handleError((path = getPathFromURL(path)), callback))
Expand Down Expand Up @@ -1249,9 +1249,7 @@ fs.futimesSync = function(fd, atime, mtime) {
binding.futimes(fd, atime, mtime);
};

function writeAll(fd, isUserFd, buffer, offset, length, position, callback_) {
var callback = maybeCallback(arguments[arguments.length - 1]);

function writeAll(fd, isUserFd, buffer, offset, length, position, callback) {
// write(fd, buffer, offset, length, position, callback)
fs.write(fd, buffer, offset, length, position, function(writeErr, written) {
if (writeErr) {
Expand Down Expand Up @@ -1282,7 +1280,7 @@ function writeAll(fd, isUserFd, buffer, offset, length, position, 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' });
const flag = options.flag || 'w';

Expand Down

0 comments on commit 84484b7

Please sign in to comment.