Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1166)

Unified Diff: src/core/SkStream.cpp

Issue 706063002: for X in {Dec,BigDec,Scalar}, SkWStream::write"X"AsText no longer mallocs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkStream.cpp
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index ff14a8b26f5606bbd576043e6729349bdbdcaf43..fe6728d7c270bdb083325eb10dcfdaa890561b57 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -87,16 +87,16 @@ bool SkWStream::writeText(const char text[])
bool SkWStream::writeDecAsText(int32_t dec)
{
- SkString tmp;
- tmp.appendS32(dec);
- return this->write(tmp.c_str(), tmp.size());
+ char buffer[SkStrAppendS32_MaxSize];
reed1 2014/11/06 21:45:09 does the buffer need to be this const + 1, to have
hal.canary 2014/11/06 22:26:30 SkWStream::write(void*, size_t) doesn't need a ter
reed1 2014/11/07 14:52:28 Ah, right. I'll add some dox so I can remind myse
+ char* stop = SkStrAppendS32(buffer, dec);
+ return this->write(buffer, stop - buffer);
}
bool SkWStream::writeBigDecAsText(int64_t dec, int minDigits)
{
- SkString tmp;
- tmp.appendS64(dec, minDigits);
- return this->write(tmp.c_str(), tmp.size());
+ char buffer[SkStrAppendU64_MaxSize];
+ char* stop = SkStrAppendU64(buffer, dec, minDigits);
+ return this->write(buffer, stop - buffer);
}
bool SkWStream::writeHexAsText(uint32_t hex, int digits)
@@ -108,9 +108,9 @@ bool SkWStream::writeHexAsText(uint32_t hex, int digits)
bool SkWStream::writeScalarAsText(SkScalar value)
{
- SkString tmp;
- tmp.appendScalar(value);
- return this->write(tmp.c_str(), tmp.size());
+ char buffer[SkStrAppendScalar_MaxSize];
+ char* stop = SkStrAppendScalar(buffer, value);
+ return this->write(buffer, stop - buffer);
}
bool SkWStream::write8(U8CPU value) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698