Skip to content

Commit

Permalink
src: remove unused parameters
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
mscdex authored and jasnell committed May 23, 2017
1 parent 1aa68f9 commit 1263b70
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1099,8 +1099,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
FSReqWrap::Ownership ownership = FSReqWrap::COPY;

// will assign buf and len if string was external
if (!StringBytes::GetExternalParts(env->isolate(),
string,
if (!StringBytes::GetExternalParts(string,
const_cast<const char**>(&buf),
&len)) {
enum encoding enc = ParseEncoding(env->isolate(), args[3], UTF8);
Expand Down
14 changes: 5 additions & 9 deletions src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ static size_t hex_decode(char* buf,
}


bool StringBytes::GetExternalParts(Isolate* isolate,
Local<Value> val,
bool StringBytes::GetExternalParts(Local<Value> val,
const char** data,
size_t* len) {
if (Buffer::HasInstance(val)) {
Expand Down Expand Up @@ -306,8 +305,6 @@ bool StringBytes::GetExternalParts(Isolate* isolate,

size_t StringBytes::WriteUCS2(char* buf,
size_t buflen,
size_t nbytes,
const char* data,
Local<String> str,
int flags,
size_t* chars_written) {
Expand Down Expand Up @@ -353,7 +350,7 @@ size_t StringBytes::Write(Isolate* isolate,
HandleScope scope(isolate);
const char* data = nullptr;
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;

CHECK(val->IsString() == true);
Expand Down Expand Up @@ -391,7 +388,7 @@ size_t StringBytes::Write(Isolate* isolate,
memcpy(buf, data, nbytes);
nchars = nbytes / sizeof(uint16_t);
} else {
nbytes = WriteUCS2(buf, buflen, nbytes, data, str, flags, &nchars);
nbytes = WriteUCS2(buf, buflen, str, flags, &nchars);
}
if (chars_written != nullptr)
*chars_written = nchars;
Expand Down Expand Up @@ -439,8 +436,7 @@ size_t StringBytes::Write(Isolate* isolate,
}


bool StringBytes::IsValidString(Isolate* isolate,
Local<String> string,
bool StringBytes::IsValidString(Local<String> string,
enum encoding enc) {
if (enc == HEX && string->Length() % 2 != 0)
return false;
Expand Down Expand Up @@ -512,7 +508,7 @@ size_t StringBytes::Size(Isolate* isolate,
return Buffer::Length(val);

const char* data;
if (GetExternalParts(isolate, val, &data, &data_size))
if (GetExternalParts(val, &data, &data_size))
return data_size;

Local<String> str = val->ToString(isolate);
Expand Down
10 changes: 3 additions & 7 deletions src/string_bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class StringBytes {
v8::Local<v8::Value> encoding,
enum 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");
return false;
}
Expand All @@ -69,8 +69,7 @@ class StringBytes {
// Does the string match the encoding? Quick but non-exhaustive.
// Example: a HEX string must have a length that's a multiple of two.
// FIXME(bnoordhuis) IsMaybeValidString()? Naming things is hard...
static bool IsValidString(v8::Isolate* isolate,
v8::Local<v8::String> string,
static bool IsValidString(v8::Local<v8::String> string,
enum encoding enc);

// Fast, but can be 2 bytes oversized for Base64, and
Expand All @@ -87,8 +86,7 @@ class StringBytes {

// If the string is external then assign external properties to data and len,
// then return true. If not return false.
static bool GetExternalParts(v8::Isolate* isolate,
v8::Local<v8::Value> val,
static bool GetExternalParts(v8::Local<v8::Value> val,
const char** data,
size_t* len);

Expand Down Expand Up @@ -125,8 +123,6 @@ class StringBytes {
private:
static size_t WriteUCS2(char* buf,
size_t buflen,
size_t nbytes,
const char* data,
v8::Local<v8::String> str,
int flags,
size_t* chars_written);
Expand Down

0 comments on commit 1263b70

Please sign in to comment.