diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-02-23 09:53:09 -0800 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-23 18:32:16 +0000 |
commit | c6dc69fb69e5d9974aa451d590194d568b78131b (patch) | |
tree | bec72acd1fee95da7d321ee700cf7aff23ecfe80 /fpdfsdk/javascript/Document.cpp | |
parent | fc54e054811510c3d7c8a9c6af6c90c3222c7029 (diff) | |
download | pdfium-c6dc69fb69e5d9974aa451d590194d568b78131b.tar.xz |
Store JS string constants as single-byte strings.
Save some space since none contain non-ascii characters.
Avoid allocating C++ WideStrings just to convert back to
UTF8 when defining properties.
Change-Id: Id94db21b32ee7a96856c35a09f7550b54599ae13
Reviewed-on: https://pdfium-review.googlesource.com/2826
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/Document.cpp')
-rw-r--r-- | fpdfsdk/javascript/Document.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index 3fdb906108..fbcd53f35a 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -766,18 +766,24 @@ bool Document::info(CJS_Runtime* pRuntime, CFX_WideString cwTrapped = pDictionary->GetUnicodeTextFor("Trapped"); v8::Local<v8::Object> pObj = pRuntime->NewFxDynamicObj(-1); - pRuntime->PutObjectProperty(pObj, L"Author", pRuntime->NewString(cwAuthor)); - pRuntime->PutObjectProperty(pObj, L"Title", pRuntime->NewString(cwTitle)); - pRuntime->PutObjectProperty(pObj, L"Subject", pRuntime->NewString(cwSubject)); + pRuntime->PutObjectProperty(pObj, L"Author", + pRuntime->NewString(cwAuthor.AsStringC())); + pRuntime->PutObjectProperty(pObj, L"Title", + pRuntime->NewString(cwTitle.AsStringC())); + pRuntime->PutObjectProperty(pObj, L"Subject", + pRuntime->NewString(cwSubject.AsStringC())); pRuntime->PutObjectProperty(pObj, L"Keywords", - pRuntime->NewString(cwKeywords)); - pRuntime->PutObjectProperty(pObj, L"Creator", pRuntime->NewString(cwCreator)); + pRuntime->NewString(cwKeywords.AsStringC())); + pRuntime->PutObjectProperty(pObj, L"Creator", + pRuntime->NewString(cwCreator.AsStringC())); pRuntime->PutObjectProperty(pObj, L"Producer", - pRuntime->NewString(cwProducer)); + pRuntime->NewString(cwProducer.AsStringC())); pRuntime->PutObjectProperty(pObj, L"CreationDate", - pRuntime->NewString(cwCreationDate)); - pRuntime->PutObjectProperty(pObj, L"ModDate", pRuntime->NewString(cwModDate)); - pRuntime->PutObjectProperty(pObj, L"Trapped", pRuntime->NewString(cwTrapped)); + pRuntime->NewString(cwCreationDate.AsStringC())); + pRuntime->PutObjectProperty(pObj, L"ModDate", + pRuntime->NewString(cwModDate.AsStringC())); + pRuntime->PutObjectProperty(pObj, L"Trapped", + pRuntime->NewString(cwTrapped.AsStringC())); // It's to be compatible to non-standard info dictionary. for (const auto& it : *pDictionary) { @@ -786,7 +792,8 @@ bool Document::info(CJS_Runtime* pRuntime, CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey.AsStringC()); if (pValueObj->IsString() || pValueObj->IsName()) { pRuntime->PutObjectProperty( - pObj, wsKey, pRuntime->NewString(pValueObj->GetUnicodeText())); + pObj, wsKey, + pRuntime->NewString(pValueObj->GetUnicodeText().AsStringC())); } else if (pValueObj->IsNumber()) { pRuntime->PutObjectProperty(pObj, wsKey, pRuntime->NewNumber(pValueObj->GetNumber())); |