From 24f3f1160659ebb83416a2c779abf9d0e87ed0d6 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 17 Feb 2019 21:19:53 +0100 Subject: [PATCH] src: move function from header to source file This particular Buffer::New() overload used to live in node_internals.h to work around a cyclic header dependency (IIRC) but that is no longer necessary. PR-URL: https://github.com/nodejs/node/pull/26173 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen Reviewed-By: Minwoo Jung Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Yuta Hiroto Reviewed-By: Ruben Bridgewater --- src/node_buffer.cc | 14 ++++++++++++++ src/node_internals.h | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 39727fcdd14179..9fed15622e05d5 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -234,6 +234,20 @@ size_t Length(Local obj) { } +inline MaybeLocal New(Environment* env, + Local ab, + size_t byte_offset, + size_t length) { + CHECK(!env->buffer_prototype_object().IsEmpty()); + Local ui = Uint8Array::New(ab, byte_offset, length); + Maybe mb = + ui->SetPrototype(env->context(), env->buffer_prototype_object()); + if (mb.IsNothing()) + return MaybeLocal(); + return ui; +} + + MaybeLocal New(Isolate* isolate, Local string, enum encoding enc) { diff --git a/src/node_internals.h b/src/node_internals.h index 367df26c0e74f6..6f09708371b97c 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -128,20 +128,6 @@ v8::MaybeLocal New(Environment* env, // Mixing operator new and free() is undefined behavior so don't do that. v8::MaybeLocal New(Environment* env, char* data, size_t length); -inline -v8::MaybeLocal New(Environment* env, - v8::Local ab, - size_t byte_offset, - size_t length) { - v8::Local ui = v8::Uint8Array::New(ab, byte_offset, length); - CHECK(!env->buffer_prototype_object().IsEmpty()); - v8::Maybe mb = - ui->SetPrototype(env->context(), env->buffer_prototype_object()); - if (mb.IsNothing()) - return v8::MaybeLocal(); - return ui; -} - // Construct a Buffer from a MaybeStackBuffer (and also its subclasses like // Utf8Value and TwoByteValue). // If |buf| is invalidated, an empty MaybeLocal is returned, and nothing is