mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #4980 from braincube-io/feat/fadoli/MakeFileReadFast
Performance : make reading single buffer / string file faster by not re-allocating and handling huge buffers
This commit is contained in:
commit
f6e565ba04
@ -339,7 +339,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
else {
|
||||
msg.filename = filename;
|
||||
var lines = Buffer.from([]);
|
||||
const bufferArray = [];
|
||||
var spare = "";
|
||||
var count = 0;
|
||||
var type = "buffer";
|
||||
@ -397,7 +397,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
lines = Buffer.concat([lines,chunk]);
|
||||
bufferArray.push(chunk);
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -413,10 +413,11 @@ module.exports = function(RED) {
|
||||
})
|
||||
.on('end', function() {
|
||||
if (node.chunk === false) {
|
||||
const buffer = Buffer.concat(bufferArray);
|
||||
if (node.format === "utf8") {
|
||||
msg.payload = decode(lines, node.encoding);
|
||||
msg.payload = decode(buffer, node.encoding);
|
||||
}
|
||||
else { msg.payload = lines; }
|
||||
else { msg.payload = buffer; }
|
||||
nodeSend(msg);
|
||||
}
|
||||
else if (node.format === "lines") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user