Browse Source

src: speed up module loading, skip EOF read

Stop reading from disk when we read fewer bytes than requested because
the next read will be the zero-sized EOF.

PR-URL: https://github.com/nodejs/node/pull/9132
Reviewed-By: James M Snell <jasnell@gmail.com>
v6
Ben Noordhuis 8 years ago
parent
commit
35e8896153
  1. 2
      src/node_file.cc

2
src/node_file.cc

@ -565,8 +565,6 @@ static void InternalModuleReadFile(const FunctionCallbackInfo<Value>& args) {
CHECK_GE(numchars, 0); CHECK_GE(numchars, 0);
if (static_cast<size_t>(numchars) < kBlockSize) { if (static_cast<size_t>(numchars) < kBlockSize) {
chars.resize(start + numchars); chars.resize(start + numchars);
}
if (numchars == 0) {
break; break;
} }
offset += numchars; offset += numchars;

Loading…
Cancel
Save