Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe-Abraham committed Dec 13, 2024
1 parent 54858d5 commit 1a864f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions velox/common/encode/Base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,16 @@ size_t Base64::calculateEncodedSize(size_t inputSize, bool withPadding) {
}

// static
Status Base64::encode(const char* input, size_t inputSize, char* output) {
void Base64::encode(const char* input, size_t inputSize, char* output) {
return encodeImpl(
folly::StringPiece(input, inputSize), kBase64Charset, true, output);
}

// static
Status
Base64::encodeUrl(const char* input, size_t inputSize, char* outputBuffer) {
void Base64::encodeUrl(
const char* input,
size_t inputSize,
char* outputBuffer) {
return encodeImpl(
folly::StringPiece(input, inputSize),
kBase64UrlCharset,
Expand All @@ -201,14 +203,14 @@ Base64::encodeUrl(const char* input, size_t inputSize, char* outputBuffer) {

// static
template <class T>
Status Base64::encodeImpl(
void Base64::encodeImpl(
const T& input,
const Charset& charset,
bool includePadding,
char* outputBuffer) {
auto inputSize = input.size();
if (inputSize == 0) {
return Status::OK();
return;
}

auto outputPointer = outputBuffer;
Expand Down Expand Up @@ -248,7 +250,6 @@ Status Base64::encodeImpl(
}
}
}
return Status::OK();
}

// static
Expand Down Expand Up @@ -322,7 +323,7 @@ void Base64::decode(
const std::pair<const char*, int32_t>& payload,
std::string& decodedOutput) {
size_t inputSize = payload.second;
size_t decodedSize;
size_t decodedSize{0};
(void)calculateDecodedSize(payload.first, inputSize, decodedSize);
decodedOutput.resize(decodedSize);
(void)decode(
Expand Down
6 changes: 3 additions & 3 deletions velox/common/encode/Base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Base64 {
/// Encodes the specified number of characters from the 'input' and writes the
/// result to the 'outputBuffer'. The output must have enough space as
/// returned by the calculateEncodedSize().
static Status encode(const char* input, size_t inputSize, char* outputBuffer);
static void encode(const char* input, size_t inputSize, char* outputBuffer);

/// Encodes the specified number of characters from the 'input' using URL
/// encoding.
Expand All @@ -68,7 +68,7 @@ class Base64 {
/// Encodes the specified number of characters from the 'input' and writes the
/// result to the 'outputBuffer' using URL encoding. The output must have
/// enough space as returned by the calculateEncodedSize().
static Status
static void
encodeUrl(const char* input, size_t inputSize, char* outputBuffer);

/// Decodes the input Base64 encoded string.
Expand Down Expand Up @@ -153,7 +153,7 @@ class Base64 {

// Encodes the specified data using the provided charset.
template <class T>
static Status encodeImpl(
static void encodeImpl(
const T& input,
const Charset& charset,
bool includePadding,
Expand Down

0 comments on commit 1a864f6

Please sign in to comment.