Skip to content

Commit 88c2f21

Browse files
committed
fix(memory): better string concatenation (#98)
1 parent c135e9c commit 88c2f21

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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)