Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix signatures to avoid a string copy #10

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/TinyGsmClientBG96.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ class TinyGsmBG96 : public TinyGsmModem<TinyGsmBG96>,
* NTP server functions
*/

byte NTPServerSyncImpl(String server = "pool.ntp.org", byte = -5) {
byte NTPServerSyncImpl(const String& server = "pool.ntp.org", byte = -5) {
// Request network synchronization
// AT+QNTP=<contextID>,<server>[,<port>][,<autosettime>]
sendAT(GF("+QNTP=1,\""), server, '"');
Expand Down
2 changes: 1 addition & 1 deletion src/TinyGsmHttpsA76xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class TinyGsmHttpsA76xx
return -1;
}

int https_post(String payload)
int https_post(const String& payload)
{
return https_post((uint8_t *) payload.c_str(), payload.length());
}
Expand Down
6 changes: 3 additions & 3 deletions src/TinyGsmNTP.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TinyGsmNTP {
*/

public:
bool TinyGsmIsValidNumber(String str) {
bool TinyGsmIsValidNumber(const String& str) {
if (!(str.charAt(0) == '+' || str.charAt(0) == '-' ||
isDigit(str.charAt(0))))
return false;
Expand All @@ -32,7 +32,7 @@ class TinyGsmNTP {
return true;
}

byte NTPServerSync(String server = "pool.ntp.org", byte TimeZone = 3) {
byte NTPServerSync(const String& server = "pool.ntp.org", byte TimeZone = 3) {
return thisModem().NTPServerSyncImpl(server, TimeZone);
}
String ShowNTPError(byte error) {
Expand All @@ -54,7 +54,7 @@ class TinyGsmNTP {
* NTP server functions
*/
protected:
byte NTPServerSyncImpl(String server = "pool.ntp.org", byte TimeZone = 3) {
byte NTPServerSyncImpl(const String& server = "pool.ntp.org", byte TimeZone = 3) {
// Set GPRS bearer profile to associate with NTP sync
// this may fail, it's not supported by all modules
thisModem().sendAT(GF("+CNTPCID=1"));
Expand Down