From 11a6becb837a16972ffda8f94c8fb69ae100f3f4 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 25 Jul 2018 23:25:55 +0000 Subject: Remove some ASSERT (and cast) in favor of checked cases. Because it is a stronger pattern at runtime. These were found by essentially: grep -ni '\bassert\b.*type' Change-Id: I913d77139053e8980528597a6633e1859e5204c4 Reviewed-on: https://pdfium-review.googlesource.com/38890 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'core/fpdfapi/edit') diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index 9693bc48ff..e2fa801a58 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -264,13 +264,20 @@ const CPDF_ContentMark* CPDF_PageContentGenerator::ProcessContentMarks( } // If there are parameters, write properties, direct or indirect. - if (item->GetParamType() == CPDF_ContentMarkItem::DirectDict) { - CPDF_StringArchiveStream archive_stream(buf); - item->GetParam()->WriteTo(&archive_stream, nullptr); - *buf << " "; - } else { - ASSERT(item->GetParamType() == CPDF_ContentMarkItem::PropertiesDict); - *buf << "/" << item->GetPropertyName() << " "; + switch (item->GetParamType()) { + case CPDF_ContentMarkItem::DirectDict: { + CPDF_StringArchiveStream archive_stream(buf); + item->GetParam()->WriteTo(&archive_stream, nullptr); + *buf << " "; + break; + } + case CPDF_ContentMarkItem::PropertiesDict: { + *buf << "/" << item->GetPropertyName() << " "; + break; + } + default: + NOTREACHED(); + break; } // Write BDC (begin dictionary content) operator. -- cgit v1.2.3