Skip to content

Commit edf2a45

Browse files
authored
Merge pull request #101 from bonitoo-io/fix/memory_alloc
fix(memory): better string concatenation
2 parents c135e9c + dd9d9ee commit edf2a45

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
### Documentation
1515
- [#87](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/87) - Fixed include file name in the Readme
16-
- [#99](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/99) - Changed default InfluxDB 2 port from 9999 to 8086 (default since rc0)
16+
- [#99](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/99) - Changed default InfluxDB 2 port from 9999 to 8086 (default since InfluxDB 2 RC0)
1717

1818
### Fixes
1919
- [#90](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/90) - Fixed boolean type recognition of InfluxDB Flux
20+
- [#101](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/101) - Better memory efficient point line composition
2021

2122
## Version 3.3.0 (2020-07-07)
2223
- [NEW] Added possibility skip server certification validation (`setInsecure()` method)

src/Point.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,18 @@ void Point::putField(String name, String value) {
6161

6262
String Point::toLineProtocol() const {
6363
String line = _measurement;
64+
line.reserve(1 + _tags.length() + 1 + _fields.length() + 1 + _timestamp.length());
6465
if(hasTags()) {
65-
line += "," + _tags;
66+
line += ",";
67+
line += _tags;
6668
}
6769
if(hasFields()) {
68-
line += " " + _fields;
70+
line += " ";
71+
line += _fields;
6972
}
7073
if(hasTime()) {
71-
line += " " + _timestamp;
74+
line += " ";
75+
line += _timestamp;
7276
}
7377
return line;
7478
}
@@ -105,10 +109,10 @@ void Point::setTime(String timestamp) {
105109
}
106110

107111
void Point::clearFields() {
108-
_fields = "";
109-
_timestamp = "";
112+
_fields = (char *)nullptr;
113+
_timestamp = (char *)nullptr;
110114
}
111115

112116
void Point:: clearTags() {
113-
_tags = "";
117+
_tags = (char *)nullptr;
114118
}

0 commit comments

Comments
 (0)