Skip to content

Commit 57208b8

Browse files
mscdexevanlucas
authored andcommitted
fs: fix permanent deoptimizations
PR-URL: #12456 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f85c3f1 commit 57208b8

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

‎lib/fs.js‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ function getOptions(options, defaultOptions){
6060
}
6161

6262
functioncopyObject(source){
63-
consttarget={};
64-
for(constkeyinsource)
63+
vartarget={};
64+
for(varkeyinsource)
6565
target[key]=source[key];
6666
returntarget;
6767
}
@@ -273,7 +273,7 @@ fs.existsSync = function(path){
273273
};
274274

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

279279
if(handleError((path=getPathFromURL(path)),callback))
@@ -1249,9 +1249,7 @@ fs.futimesSync = function(fd, atime, mtime){
12491249
binding.futimes(fd,atime,mtime);
12501250
};
12511251

1252-
functionwriteAll(fd,isUserFd,buffer,offset,length,position,callback_){
1253-
varcallback=maybeCallback(arguments[arguments.length-1]);
1254-
1252+
functionwriteAll(fd,isUserFd,buffer,offset,length,position,callback){
12551253
// write(fd, buffer, offset, length, position, callback)
12561254
fs.write(fd,buffer,offset,length,position,function(writeErr,written){
12571255
if(writeErr){
@@ -1282,7 +1280,7 @@ function writeAll(fd, isUserFd, buffer, offset, length, position, callback_){
12821280
}
12831281

12841282
fs.writeFile=function(path,data,options,callback){
1285-
callback=maybeCallback(arguments[arguments.length-1]);
1283+
callback=maybeCallback(callback||options);
12861284
options=getOptions(options,{encoding: 'utf8',mode: 0o666,flag: 'w'});
12871285
constflag=options.flag||'w';
12881286

0 commit comments

Comments
(0)