diff options
author | halcanary <halcanary@google.com> | 2015-04-25 06:45:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-25 06:45:07 -0700 |
commit | 130444fdaf737c5931a934018ab50b0c91a3499e (patch) | |
tree | 9e853af14d9b8b3e38b344340379b74e1a27e475 /src/pdf/SkPDFResourceDict.cpp | |
parent | 8e71d38126df1ed40ee88107e681c8b62f726e30 (diff) |
SkPDF: Refactor SkPDFObject heiararchy.
Flatten and use a tagged union type
Δmemory ~= -2.4% ± 0.5%
Δtime ~= -1.2% ± 0.2%
BUG=skia:3585
Review URL: https://codereview.chromium.org/1069103003
Diffstat (limited to 'src/pdf/SkPDFResourceDict.cpp')
-rw-r--r-- | src/pdf/SkPDFResourceDict.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/pdf/SkPDFResourceDict.cpp b/src/pdf/SkPDFResourceDict.cpp index de5c910c20..1f5bceac9c 100644 --- a/src/pdf/SkPDFResourceDict.cpp +++ b/src/pdf/SkPDFResourceDict.cpp @@ -46,7 +46,7 @@ static char get_resource_type_prefix( static const char* get_resource_type_name( SkPDFResourceDict::SkPDFResourceType type) { SkASSERT(type >= 0); - SkASSERT(type < SkPDFResourceDict::kResourceTypeCount); + SkASSERT(type < SK_ARRAY_COUNT(resource_type_names)); return resource_type_names[type]; } @@ -67,13 +67,10 @@ static void add_subdict( } SkAutoTUnref<SkPDFDict> resources(SkNEW(SkPDFDict)); for (int i = 0; i < resourceList.count(); i++) { - SkString keyString = SkPDFResourceDict::getResourceName(type, i); - SkAutoTUnref<SkPDFName> keyName(SkNEW_ARGS(SkPDFName, (keyString))); - SkAutoTUnref<SkPDFObjRef> ref( - SkNEW_ARGS(SkPDFObjRef, (resourceList[i]))); - resources->insert(keyName, ref); + resources->insertObjRef(SkPDFResourceDict::getResourceName(type, i), + SkRef(resourceList[i])); } - dst->insert(get_resource_type_name(type), resources); + dst->insertObject(get_resource_type_name(type), resources.detach()); } SkPDFDict* SkPDFResourceDict::Create( @@ -90,7 +87,7 @@ SkPDFDict* SkPDFResourceDict::Create( for (size_t i = 0; i < SK_ARRAY_COUNT(kProcs); i++) { procSets->appendName(kProcs[i]); } - dict->insert("ProcSets", procSets); + dict->insertObject("ProcSets", procSets.detach()); if (gStateResources) { add_subdict(*gStateResources, kExtGState_ResourceType, dict); |