Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! src: migrate String::Value to `String::…
Browse files Browse the repository at this point in the history
…ValueView`
  • Loading branch information
avivkeller committed Oct 21, 2024
1 parent 15937ab commit 862d75c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,10 @@ size_t StringBytes::Write(Isolate* isolate,
input_view.length());
}
} else {
String::ValueView value(isolate, str);
size_t written_len = buflen;
auto result = simdutf::base64_to_binary_safe(
reinterpret_cast<const char16_t*>(value.data16()),
value.length(),
reinterpret_cast<const char16_t*>(input_view.data16()),
input_view.length(),
buf,
written_len,
simdutf::base64_url);
Expand All @@ -319,8 +318,8 @@ size_t StringBytes::Write(Isolate* isolate,
// The input does not follow the WHATWG forgiving-base64 specification
// (adapted for base64url with + and / replaced by - and _).
// https://infra.spec.whatwg.org/#forgiving-base64-decode
nbytes =
nbytes::Base64Decode(buf, buflen, value.data16(), value.length());
nbytes = nbytes::Base64Decode(
buf, buflen, input_view.data16(), input_view.length());
}
}
break;
Expand All @@ -345,20 +344,19 @@ size_t StringBytes::Write(Isolate* isolate,
input_view.length());
}
} else {
String::ValueView value(isolate, str);
size_t written_len = buflen;
auto result = simdutf::base64_to_binary_safe(
reinterpret_cast<const char16_t*>(value.data16()),
value.length(),
reinterpret_cast<const char16_t*>(input_view.data16()),
input_view.length(),
buf,
written_len);
if (result.error == simdutf::error_code::SUCCESS) {
nbytes = written_len;
} else {
// The input does not follow the WHATWG base64 specification
// https://infra.spec.whatwg.org/#forgiving-base64-decode
nbytes =
nbytes::Base64Decode(buf, buflen, value.data16(), value.length());
nbytes = nbytes::Base64Decode(
buf, buflen, input_view.data16(), input_view.length());
}
}
break;
Expand Down

0 comments on commit 862d75c

Please sign in to comment.