Skip to content

Commit

Permalink
Merge pull request #10 from mathieucarbou/const-and-ref
Browse files Browse the repository at this point in the history
Fix signatures to avoid a string copy
  • Loading branch information
lewisxhe authored Mar 28, 2024
2 parents 57f4c84 + 13d4789 commit 9cd1fed
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
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

0 comments on commit 9cd1fed

Please sign in to comment.