Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6f70e27

Browse filesBrowse files
dirkmuellerme-no-dev
authored andcommitted
Base64::encode : const correctness / String by reference passing (espressif#3314)
Avoid passing String by-value, which is slightly less efficient as it involves a full copy-constructor/tempstring creation.
1 parent d0b064a commit 6f70e27
Copy full SHA for 6f70e27

File tree

Expand file treeCollapse file tree

2 files changed

+6
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-6
lines changed

‎cores/esp32/base64.cpp

Copy file name to clipboardExpand all lines: cores/esp32/base64.cpp
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ extern "C" {
3131

3232
/**
3333
* convert input data to base64
34-
* @param data uint8_t *
34+
* @param data const uint8_t *
3535
* @param length size_t
3636
* @return String
3737
*/
38-
String base64::encode(uint8_t * data, size_t length)
38+
String base64::encode(const uint8_t * data, size_t length)
3939
{
4040
size_t size = base64_encode_expected_len(length) + 1;
4141
char * buffer = (char *) malloc(size);
@@ -54,10 +54,10 @@ String base64::encode(uint8_t * data, size_t length)
5454

5555
/**
5656
* convert input data to base64
57-
* @param text String
57+
* @param text const String&
5858
* @return String
5959
*/
60-
String base64::encode(String text)
60+
String base64::encode(const String& text)
6161
{
6262
return base64::encode((uint8_t *) text.c_str(), text.length());
6363
}

‎cores/esp32/base64.h

Copy file name to clipboardExpand all lines: cores/esp32/base64.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
class base64
55
{
66
public:
7-
static String encode(uint8_t * data, size_t length);
8-
static String encode(String text);
7+
static String encode(const uint8_t * data, size_t length);
8+
static String encode(const String& text);
99
private:
1010
};
1111

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.