summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-03-10 21:45:17 +0000
committerRuben Bridgewater <ruben@bridgewater.de>2019-03-22 00:53:11 +0100
commitb05fbaab43509078797cb46a12f54bb7cdea2443 (patch)
tree336a8833abe36f618cdcb182378e9a414dee5f0d /src
parentc97851dcd8c5e96a3601df52edd456922399a80b (diff)
downloadandroid-node-v8-b05fbaab43509078797cb46a12f54bb7cdea2443.tar.gz
android-node-v8-b05fbaab43509078797cb46a12f54bb7cdea2443.tar.bz2
android-node-v8-b05fbaab43509078797cb46a12f54bb7cdea2443.zip
src: add fast path for equal size to `Reallocate()`
When old and new size match, we can skip the rest of the function, which makes sense in the case of embedders who do not use Node's allocator, as that would lead to needlessly allocating and freeing buffers of identical sizes. PR-URL: https://github.com/nodejs/node/pull/26573 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/env.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/env.cc b/src/env.cc
index 292b8ae8de..47fabf5e2b 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -859,6 +859,7 @@ void Environment::BuildEmbedderGraph(Isolate* isolate,
}
char* Environment::Reallocate(char* data, size_t old_size, size_t size) {
+ if (old_size == size) return data;
// If we know that the allocator is our ArrayBufferAllocator, we can let
// if reallocate directly.
if (isolate_data()->uses_node_allocator()) {