Commit 6f70e270 authored by Dirk Mueller's avatar Dirk Mueller Committed by Me No Dev

Base64::encode : const correctness / String by reference passing (#3314)

Avoid passing String by-value, which is slightly less efficient
as it involves a full copy-constructor/tempstring creation.
parent d0b064a1
......@@ -31,11 +31,11 @@ extern "C" {
/**
* convert input data to base64
* @param data uint8_t *
* @param data const uint8_t *
* @param length size_t
* @return String
*/
String base64::encode(uint8_t * data, size_t length)
String base64::encode(const uint8_t * data, size_t length)
{
size_t size = base64_encode_expected_len(length) + 1;
char * buffer = (char *) malloc(size);
......@@ -54,10 +54,10 @@ String base64::encode(uint8_t * data, size_t length)
/**
* convert input data to base64
* @param text String
* @param text const String&
* @return String
*/
String base64::encode(String text)
String base64::encode(const String& text)
{
return base64::encode((uint8_t *) text.c_str(), text.length());
}
......
......@@ -4,8 +4,8 @@
class base64
{
public:
static String encode(uint8_t * data, size_t length);
static String encode(String text);
static String encode(const uint8_t * data, size_t length);
static String encode(const String& text);
private:
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment