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

Side by Side Diff: src/pdf/SkPDFMetadata.cpp

Issue 1863393004: SkPDF: fix pessimizing-move in PDFA code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkMilestone.h" 8 #include "SkMilestone.h"
9 #include "SkPDFMetadata.h" 9 #include "SkPDFMetadata.h"
10 #include "SkPDFTypes.h" 10 #include "SkPDFTypes.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 length = _vscprintf(format, args); 115 length = _vscprintf(format, args);
116 va_end(args); 116 va_end(args);
117 117
118 SkString string((size_t)length); 118 SkString string((size_t)length);
119 va_start(args, format); 119 va_start(args, format);
120 SkDEBUGCODE(int check = ) _vsnprintf_s(string.writable_str(), length + 1, 120 SkDEBUGCODE(int check = ) _vsnprintf_s(string.writable_str(), length + 1,
121 _TRUNCATE, format, args); 121 _TRUNCATE, format, args);
122 va_end(args); 122 va_end(args);
123 SkASSERT(check == length); 123 SkASSERT(check == length);
124 SkASSERT(string[length] == '\0'); 124 SkASSERT(string[length] == '\0');
125 return std::move(string); 125 return string;
126 #else // C99/C++11 standard vsnprintf 126 #else // C99/C++11 standard vsnprintf
127 // TODO: When all compilers support this, remove windows-specific code. 127 // TODO: When all compilers support this, remove windows-specific code.
128 va_list args; 128 va_list args;
129 va_start(args, format); 129 va_start(args, format);
130 char buffer[1024]; 130 char buffer[1024];
131 int length = vsnprintf(buffer, sizeof(buffer), format, args); 131 int length = vsnprintf(buffer, sizeof(buffer), format, args);
132 va_end(args); 132 va_end(args);
133 if (length < 0) { 133 if (length < 0) {
134 return SkString(); 134 return SkString();
135 } 135 }
136 if (length < (int)sizeof(buffer)) { 136 if (length < (int)sizeof(buffer)) {
137 return SkString(buffer, length); 137 return SkString(buffer, length);
138 } 138 }
139 SkString string((size_t)length); 139 SkString string((size_t)length);
140 va_start(args, format); 140 va_start(args, format);
141 SkDEBUGCODE(int check = ) 141 SkDEBUGCODE(int check = )
142 vsnprintf(string.writable_str(), length + 1, format, args); 142 vsnprintf(string.writable_str(), length + 1, format, args);
143 va_end(args); 143 va_end(args);
144 SkASSERT(check == length); 144 SkASSERT(check == length);
145 SkASSERT(string[length] == '\0'); 145 SkASSERT(string[length] == '\0');
146 return std::move(string); 146 return string;
147 #endif 147 #endif
148 } 148 }
149 149
150 static const SkString get(const SkTArray<SkDocument::Attribute>& info, 150 static const SkString get(const SkTArray<SkDocument::Attribute>& info,
151 const char* key) { 151 const char* key) {
152 for (const auto& keyValue : info) { 152 for (const auto& keyValue : info) {
153 if (keyValue.fKey.equals(key)) { 153 if (keyValue.fKey.equals(key)) {
154 return keyValue.fValue; 154 return keyValue.fValue;
155 } 155 }
156 } 156 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 creator.c_str(), title.c_str(), 348 creator.c_str(), title.c_str(),
349 subject.c_str(), author.c_str(), keywords1.c_str(), 349 subject.c_str(), author.c_str(), keywords1.c_str(),
350 documentID.c_str(), instanceID.c_str(), keywords2.c_str())); 350 documentID.c_str(), instanceID.c_str(), keywords2.c_str()));
351 } 351 }
352 352
353 #endif // SK_PDF_GENERATE_PDFA 353 #endif // SK_PDF_GENERATE_PDFA
354 354
355 #undef SKPDF_STRING 355 #undef SKPDF_STRING
356 #undef SKPDF_STRING_IMPL 356 #undef SKPDF_STRING_IMPL
357 357
OLDNEW
« 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