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

Side by Side Diff: core/fpdfdoc/doc_utils.cpp

Issue 1891953002: Avoid needless construction of CFX_ByteStrings during string building (Closed) Base URL: https://pdfium.googlesource.com/pdfium.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 | xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" 10 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 CPDF_SimpleParser syntax(m_csDA.AsStringC()); 84 CPDF_SimpleParser syntax(m_csDA.AsStringC());
85 return syntax.FindTagParamFromStart("Tf", 2); 85 return syntax.FindTagParamFromStart("Tf", 2);
86 } 86 }
87 CFX_ByteString CPDF_DefaultAppearance::GetFontString() { 87 CFX_ByteString CPDF_DefaultAppearance::GetFontString() {
88 CFX_ByteString csFont; 88 CFX_ByteString csFont;
89 if (m_csDA.IsEmpty()) { 89 if (m_csDA.IsEmpty()) {
90 return csFont; 90 return csFont;
91 } 91 }
92 CPDF_SimpleParser syntax(m_csDA.AsStringC()); 92 CPDF_SimpleParser syntax(m_csDA.AsStringC());
93 if (syntax.FindTagParamFromStart("Tf", 2)) { 93 if (syntax.FindTagParamFromStart("Tf", 2)) {
94 csFont += (CFX_ByteString)syntax.GetWord(); 94 csFont += syntax.GetWord();
95 csFont += " "; 95 csFont += " ";
96 csFont += (CFX_ByteString)syntax.GetWord(); 96 csFont += syntax.GetWord();
97 csFont += " "; 97 csFont += " ";
98 csFont += (CFX_ByteString)syntax.GetWord(); 98 csFont += syntax.GetWord();
99 } 99 }
100 return csFont; 100 return csFont;
101 } 101 }
102 void CPDF_DefaultAppearance::GetFont(CFX_ByteString& csFontNameTag, 102 void CPDF_DefaultAppearance::GetFont(CFX_ByteString& csFontNameTag,
103 FX_FLOAT& fFontSize) { 103 FX_FLOAT& fFontSize) {
104 csFontNameTag = ""; 104 csFontNameTag = "";
105 fFontSize = 0; 105 fFontSize = 0;
106 if (m_csDA.IsEmpty()) { 106 if (m_csDA.IsEmpty()) {
107 return; 107 return;
108 } 108 }
(...skipping 19 matching lines...) Expand all
128 return syntax.FindTagParamFromStart(bStrokingOperation ? "K" : "k", 4); 128 return syntax.FindTagParamFromStart(bStrokingOperation ? "K" : "k", 4);
129 } 129 }
130 CFX_ByteString CPDF_DefaultAppearance::GetColorString( 130 CFX_ByteString CPDF_DefaultAppearance::GetColorString(
131 FX_BOOL bStrokingOperation) { 131 FX_BOOL bStrokingOperation) {
132 CFX_ByteString csColor; 132 CFX_ByteString csColor;
133 if (m_csDA.IsEmpty()) { 133 if (m_csDA.IsEmpty()) {
134 return csColor; 134 return csColor;
135 } 135 }
136 CPDF_SimpleParser syntax(m_csDA.AsStringC()); 136 CPDF_SimpleParser syntax(m_csDA.AsStringC());
137 if (syntax.FindTagParamFromStart(bStrokingOperation ? "G" : "g", 1)) { 137 if (syntax.FindTagParamFromStart(bStrokingOperation ? "G" : "g", 1)) {
138 csColor += (CFX_ByteString)syntax.GetWord(); 138 csColor += syntax.GetWord();
139 csColor += " "; 139 csColor += " ";
140 csColor += (CFX_ByteString)syntax.GetWord(); 140 csColor += syntax.GetWord();
141 return csColor; 141 return csColor;
142 } 142 }
143 if (syntax.FindTagParamFromStart(bStrokingOperation ? "RG" : "rg", 3)) { 143 if (syntax.FindTagParamFromStart(bStrokingOperation ? "RG" : "rg", 3)) {
144 csColor += (CFX_ByteString)syntax.GetWord(); 144 csColor += syntax.GetWord();
145 csColor += " "; 145 csColor += " ";
146 csColor += (CFX_ByteString)syntax.GetWord(); 146 csColor += syntax.GetWord();
147 csColor += " "; 147 csColor += " ";
148 csColor += (CFX_ByteString)syntax.GetWord(); 148 csColor += syntax.GetWord();
149 csColor += " "; 149 csColor += " ";
150 csColor += (CFX_ByteString)syntax.GetWord(); 150 csColor += syntax.GetWord();
151 return csColor; 151 return csColor;
152 } 152 }
153 if (syntax.FindTagParamFromStart(bStrokingOperation ? "K" : "k", 4)) { 153 if (syntax.FindTagParamFromStart(bStrokingOperation ? "K" : "k", 4)) {
154 csColor += (CFX_ByteString)syntax.GetWord(); 154 csColor += syntax.GetWord();
155 csColor += " "; 155 csColor += " ";
156 csColor += (CFX_ByteString)syntax.GetWord(); 156 csColor += syntax.GetWord();
157 csColor += " "; 157 csColor += " ";
158 csColor += (CFX_ByteString)syntax.GetWord(); 158 csColor += syntax.GetWord();
159 csColor += " "; 159 csColor += " ";
160 csColor += (CFX_ByteString)syntax.GetWord(); 160 csColor += syntax.GetWord();
161 csColor += " "; 161 csColor += " ";
162 csColor += (CFX_ByteString)syntax.GetWord(); 162 csColor += syntax.GetWord();
163 } 163 }
164 return csColor; 164 return csColor;
165 } 165 }
166 void CPDF_DefaultAppearance::GetColor(int& iColorType, 166 void CPDF_DefaultAppearance::GetColor(int& iColorType,
167 FX_FLOAT fc[4], 167 FX_FLOAT fc[4],
168 FX_BOOL bStrokingOperation) { 168 FX_BOOL bStrokingOperation) {
169 iColorType = COLORTYPE_TRANSPARENT; 169 iColorType = COLORTYPE_TRANSPARENT;
170 for (int c = 0; c < 4; c++) { 170 for (int c = 0; c < 4; c++) {
171 fc[c] = 0; 171 fc[c] = 0;
172 } 172 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return syntax.FindTagParamFromStart("Tm", 6); 238 return syntax.FindTagParamFromStart("Tm", 6);
239 } 239 }
240 CFX_ByteString CPDF_DefaultAppearance::GetTextMatrixString() { 240 CFX_ByteString CPDF_DefaultAppearance::GetTextMatrixString() {
241 CFX_ByteString csTM; 241 CFX_ByteString csTM;
242 if (m_csDA.IsEmpty()) { 242 if (m_csDA.IsEmpty()) {
243 return csTM; 243 return csTM;
244 } 244 }
245 CPDF_SimpleParser syntax(m_csDA.AsStringC()); 245 CPDF_SimpleParser syntax(m_csDA.AsStringC());
246 if (syntax.FindTagParamFromStart("Tm", 6)) { 246 if (syntax.FindTagParamFromStart("Tm", 6)) {
247 for (int i = 0; i < 6; i++) { 247 for (int i = 0; i < 6; i++) {
248 csTM += (CFX_ByteString)syntax.GetWord(); 248 csTM += syntax.GetWord();
249 csTM += " "; 249 csTM += " ";
250 } 250 }
251 csTM += (CFX_ByteString)syntax.GetWord(); 251 csTM += syntax.GetWord();
252 } 252 }
253 return csTM; 253 return csTM;
254 } 254 }
255 CFX_Matrix CPDF_DefaultAppearance::GetTextMatrix() { 255 CFX_Matrix CPDF_DefaultAppearance::GetTextMatrix() {
256 CFX_Matrix tm; 256 CFX_Matrix tm;
257 if (m_csDA.IsEmpty()) { 257 if (m_csDA.IsEmpty()) {
258 return tm; 258 return tm;
259 } 259 }
260 CPDF_SimpleParser syntax(m_csDA.AsStringC()); 260 CPDF_SimpleParser syntax(m_csDA.AsStringC());
261 if (syntax.FindTagParamFromStart("Tm", 6)) { 261 if (syntax.FindTagParamFromStart("Tm", 6)) {
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 CPDF_Object* pAttr = pFieldDict->GetDirectObjectBy(name); 745 CPDF_Object* pAttr = pFieldDict->GetDirectObjectBy(name);
746 if (pAttr) { 746 if (pAttr) {
747 return pAttr; 747 return pAttr;
748 } 748 }
749 CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent"); 749 CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent");
750 if (!pParent) { 750 if (!pParent) {
751 return NULL; 751 return NULL;
752 } 752 }
753 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); 753 return FPDF_GetFieldAttr(pParent, name, nLevel + 1);
754 } 754 }
OLDNEW
« no previous file with comments | « no previous file | xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698