On Fri, Jun 1, 2012 at 10:41 AM, Jason <[email protected]> wrote: > Hi > > I found following code in fs.js: > > > fs.readFileSync = function(path, encoding) { > > var fd = fs.openSync(path, constants.O_RDONLY, 438 /*=0666*/); > > var buffer = new Buffer(4048); > > var buffers = []; > > var nread = 0; > > var lastRead = 0; > > > try { > > do { > if (lastRead) { > > buffer._bytesRead = lastRead; > > nread += lastRead; > > buffers.push(buffer); > > } > var buffer = new Buffer(4048); > > lastRead = fs.readSync(fd, buffer, 0, buffer.length, null); > > } while (lastRead > 0); > > } finally { > > fs.closeSync(fd); > > } > // ...... > > > It seems that the buffer allocation at the start of function is needless > because the code 'var buffer = new Buffer(4048);' in loop works at least > once
That alloc was removed some time ago in the master branch.
