src: remove unused parameters
PR-URL: https://github.com/nodejs/node/pull/13085 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ron Korving <ron@ronkorving.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
parent
c470f04f22
commit
f529706eb0
@ -1099,8 +1099,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
|
|||||||
FSReqWrap::Ownership ownership = FSReqWrap::COPY;
|
FSReqWrap::Ownership ownership = FSReqWrap::COPY;
|
||||||
|
|
||||||
// will assign buf and len if string was external
|
// will assign buf and len if string was external
|
||||||
if (!StringBytes::GetExternalParts(env->isolate(),
|
if (!StringBytes::GetExternalParts(string,
|
||||||
string,
|
|
||||||
const_cast<const char**>(&buf),
|
const_cast<const char**>(&buf),
|
||||||
&len)) {
|
&len)) {
|
||||||
enum encoding enc = ParseEncoding(env->isolate(), args[3], UTF8);
|
enum encoding enc = ParseEncoding(env->isolate(), args[3], UTF8);
|
||||||
|
@ -270,8 +270,7 @@ static size_t hex_decode(char* buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool StringBytes::GetExternalParts(Isolate* isolate,
|
bool StringBytes::GetExternalParts(Local<Value> val,
|
||||||
Local<Value> val,
|
|
||||||
const char** data,
|
const char** data,
|
||||||
size_t* len) {
|
size_t* len) {
|
||||||
if (Buffer::HasInstance(val)) {
|
if (Buffer::HasInstance(val)) {
|
||||||
@ -306,8 +305,6 @@ bool StringBytes::GetExternalParts(Isolate* isolate,
|
|||||||
|
|
||||||
size_t StringBytes::WriteUCS2(char* buf,
|
size_t StringBytes::WriteUCS2(char* buf,
|
||||||
size_t buflen,
|
size_t buflen,
|
||||||
size_t nbytes,
|
|
||||||
const char* data,
|
|
||||||
Local<String> str,
|
Local<String> str,
|
||||||
int flags,
|
int flags,
|
||||||
size_t* chars_written) {
|
size_t* chars_written) {
|
||||||
@ -353,7 +350,7 @@ size_t StringBytes::Write(Isolate* isolate,
|
|||||||
HandleScope scope(isolate);
|
HandleScope scope(isolate);
|
||||||
const char* data = nullptr;
|
const char* data = nullptr;
|
||||||
size_t nbytes = 0;
|
size_t nbytes = 0;
|
||||||
const bool is_extern = GetExternalParts(isolate, val, &data, &nbytes);
|
const bool is_extern = GetExternalParts(val, &data, &nbytes);
|
||||||
const size_t external_nbytes = nbytes;
|
const size_t external_nbytes = nbytes;
|
||||||
|
|
||||||
CHECK(val->IsString() == true);
|
CHECK(val->IsString() == true);
|
||||||
@ -391,7 +388,7 @@ size_t StringBytes::Write(Isolate* isolate,
|
|||||||
memcpy(buf, data, nbytes);
|
memcpy(buf, data, nbytes);
|
||||||
nchars = nbytes / sizeof(uint16_t);
|
nchars = nbytes / sizeof(uint16_t);
|
||||||
} else {
|
} else {
|
||||||
nbytes = WriteUCS2(buf, buflen, nbytes, data, str, flags, &nchars);
|
nbytes = WriteUCS2(buf, buflen, str, flags, &nchars);
|
||||||
}
|
}
|
||||||
if (chars_written != nullptr)
|
if (chars_written != nullptr)
|
||||||
*chars_written = nchars;
|
*chars_written = nchars;
|
||||||
@ -439,8 +436,7 @@ size_t StringBytes::Write(Isolate* isolate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool StringBytes::IsValidString(Isolate* isolate,
|
bool StringBytes::IsValidString(Local<String> string,
|
||||||
Local<String> string,
|
|
||||||
enum encoding enc) {
|
enum encoding enc) {
|
||||||
if (enc == HEX && string->Length() % 2 != 0)
|
if (enc == HEX && string->Length() % 2 != 0)
|
||||||
return false;
|
return false;
|
||||||
@ -512,7 +508,7 @@ size_t StringBytes::Size(Isolate* isolate,
|
|||||||
return Buffer::Length(val);
|
return Buffer::Length(val);
|
||||||
|
|
||||||
const char* data;
|
const char* data;
|
||||||
if (GetExternalParts(isolate, val, &data, &data_size))
|
if (GetExternalParts(val, &data, &data_size))
|
||||||
return data_size;
|
return data_size;
|
||||||
|
|
||||||
Local<String> str = val->ToString(isolate);
|
Local<String> str = val->ToString(isolate);
|
||||||
|
@ -43,7 +43,7 @@ class StringBytes {
|
|||||||
v8::Local<v8::Value> encoding,
|
v8::Local<v8::Value> encoding,
|
||||||
enum encoding _default) {
|
enum encoding _default) {
|
||||||
enum encoding enc = ParseEncoding(env->isolate(), encoding, _default);
|
enum encoding enc = ParseEncoding(env->isolate(), encoding, _default);
|
||||||
if (!StringBytes::IsValidString(env->isolate(), string, enc)) {
|
if (!StringBytes::IsValidString(string, enc)) {
|
||||||
env->ThrowTypeError("Bad input string");
|
env->ThrowTypeError("Bad input string");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -69,8 +69,7 @@ class StringBytes {
|
|||||||
// Does the string match the encoding? Quick but non-exhaustive.
|
// Does the string match the encoding? Quick but non-exhaustive.
|
||||||
// Example: a HEX string must have a length that's a multiple of two.
|
// Example: a HEX string must have a length that's a multiple of two.
|
||||||
// FIXME(bnoordhuis) IsMaybeValidString()? Naming things is hard...
|
// FIXME(bnoordhuis) IsMaybeValidString()? Naming things is hard...
|
||||||
static bool IsValidString(v8::Isolate* isolate,
|
static bool IsValidString(v8::Local<v8::String> string,
|
||||||
v8::Local<v8::String> string,
|
|
||||||
enum encoding enc);
|
enum encoding enc);
|
||||||
|
|
||||||
// Fast, but can be 2 bytes oversized for Base64, and
|
// Fast, but can be 2 bytes oversized for Base64, and
|
||||||
@ -87,8 +86,7 @@ class StringBytes {
|
|||||||
|
|
||||||
// If the string is external then assign external properties to data and len,
|
// If the string is external then assign external properties to data and len,
|
||||||
// then return true. If not return false.
|
// then return true. If not return false.
|
||||||
static bool GetExternalParts(v8::Isolate* isolate,
|
static bool GetExternalParts(v8::Local<v8::Value> val,
|
||||||
v8::Local<v8::Value> val,
|
|
||||||
const char** data,
|
const char** data,
|
||||||
size_t* len);
|
size_t* len);
|
||||||
|
|
||||||
@ -125,8 +123,6 @@ class StringBytes {
|
|||||||
private:
|
private:
|
||||||
static size_t WriteUCS2(char* buf,
|
static size_t WriteUCS2(char* buf,
|
||||||
size_t buflen,
|
size_t buflen,
|
||||||
size_t nbytes,
|
|
||||||
const char* data,
|
|
||||||
v8::Local<v8::String> str,
|
v8::Local<v8::String> str,
|
||||||
int flags,
|
int flags,
|
||||||
size_t* chars_written);
|
size_t* chars_written);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user