/** * An optimization for the slowness of calling UnicodeString::append() * one character at a time in a loop. It stores appends in a buffer while * never actually calling append on the unicode string unless the buffer * fills up or is flushed. * * proper usage: * { * UnicodeStringAppender appender(astring); * for (int32_t i = 0; i < 100; ++i) { * appender.append((char16_t) i); * } * // appender flushed automatically when it goes out of scope. * }
*/ class UnicodeStringAppender : public UMemory { public:
/** * dest is the UnicodeString being appended to. It must always * exist while this instance exists.
*/
UnicodeStringAppender(UnicodeString &dest) : fDest(&dest), fIdx(0) { }
/** * Ensures that all appended characters have been written out to dest.
*/ inlinevoid flush() { if (fIdx) {
fDest->append(fBuffer, 0, fIdx);
}
fIdx = 0;
}
/** * flush the buffer when we go out of scope.
*/
~UnicodeStringAppender() {
flush();
} private:
UnicodeString *fDest;
int32_t fIdx;
char16_t fBuffer[32];
UnicodeStringAppender(const UnicodeStringAppender &other);
UnicodeStringAppender &operator=(const UnicodeStringAppender &other);
};
U_NAMESPACE_END
#endif
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-07)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.