[poppler] poppler/FontInfo.cc poppler/GfxFont.cc poppler/StructElement.cc poppler/TextOutputDev.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Oct 1 15:56:37 UTC 2019
poppler/FontInfo.cc | 4 ++--
poppler/GfxFont.cc | 4 ++--
poppler/StructElement.cc | 24 ++++++++++++------------
poppler/TextOutputDev.cc | 7 +++----
4 files changed, 19 insertions(+), 20 deletions(-)
New commits:
commit 144a07e4b4298e272c0d5e565ec587806da2ebbc
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue Oct 1 17:45:10 2019 +0200
Use range for loops to iterate const arrays
for (const TypeMapEntry &entry : typeMap) {
is much easier to read than
for (unsigned i = 0; i < sizeof(typeMap) / sizeof(typeMap[0]); i++) {
diff --git a/poppler/FontInfo.cc b/poppler/FontInfo.cc
index c36a2d28..39557894 100644
--- a/poppler/FontInfo.cc
+++ b/poppler/FontInfo.cc
@@ -126,8 +126,8 @@ void FontInfoScanner::scanFonts(XRef *xrefA, Dict *resDict, std::vector<FontInfo
// recursively scan any resource dictionaries in objects in this
// resource dictionary
const char *resTypes[] = { "XObject", "Pattern" };
- for (unsigned int resType = 0; resType < sizeof(resTypes) / sizeof(resTypes[0]); ++resType) {
- Object objDict = resDict->lookup(resTypes[resType]);
+ for (const char *resType : resTypes) {
+ Object objDict = resDict->lookup(resType);
if (objDict.isDict()) {
for (int i = 0; i < objDict.dictGetLength(); ++i) {
Ref obj2Ref;
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index cdf8975b..af3aa221 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -1796,8 +1796,8 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA,
"Adobe-Japan2",
"Adobe-Korea1",
};
- for (size_t i = 0; i < sizeof(knownCollections)/sizeof(knownCollections[0]); i++) {
- if (collection->cmp(knownCollections[i]) == 0) {
+ for (const char *knownCollection : knownCollections) {
+ if (collection->cmp(knownCollection) == 0) {
error(errSyntaxError, -1, "Missing language pack for '{0:t}' mapping", collection);
return;
}
diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc
index 19bac494..3ad314ce 100644
--- a/poppler/StructElement.cc
+++ b/poppler/StructElement.cc
@@ -592,18 +592,18 @@ getAttributeMapEntry(const AttributeMapEntry **entryList, const char *name)
static inline const OwnerMapEntry *getOwnerMapEntry(Attribute::Owner owner)
{
- for (unsigned i = 0; i < sizeof(ownerMap) / sizeof(ownerMap[0]); i++) {
- if (owner == ownerMap[i].owner)
- return &ownerMap[i];
+ for (const OwnerMapEntry &entry : ownerMap) {
+ if (owner == entry.owner)
+ return &entry;
}
return nullptr;
}
static inline const OwnerMapEntry *getOwnerMapEntry(const char *name)
{
- for (unsigned i = 0; i < sizeof(ownerMap) / sizeof(ownerMap[0]); i++) {
- if (strcmp(name, ownerMap[i].name) == 0)
- return &ownerMap[i];
+ for (const OwnerMapEntry &entry : ownerMap) {
+ if (strcmp(name, entry.name) == 0)
+ return &entry;
}
return nullptr;
}
@@ -622,18 +622,18 @@ static Attribute::Owner nameToOwner(const char *name)
static inline const TypeMapEntry *getTypeMapEntry(StructElement::Type type)
{
- for (unsigned i = 0; i < sizeof(typeMap) / sizeof(typeMap[0]); i++) {
- if (type == typeMap[i].type)
- return &typeMap[i];
+ for (const TypeMapEntry &entry : typeMap) {
+ if (type == entry.type)
+ return &entry;
}
return nullptr;
}
static inline const TypeMapEntry *getTypeMapEntry(const char *name)
{
- for (unsigned i = 0; i < sizeof(typeMap) / sizeof(typeMap[0]); i++) {
- if (strcmp(name, typeMap[i].name) == 0)
- return &typeMap[i];
+ for (const TypeMapEntry &entry : typeMap) {
+ if (strcmp(name, entry.name) == 0)
+ return &entry;
}
return nullptr;
}
diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 4021813c..65ded8cb 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -576,10 +576,9 @@ static struct CombiningTable combiningTable[] = {
// returning combining versions of characters
static Unicode getCombiningChar(Unicode u) {
- int len = sizeof(combiningTable) / sizeof(combiningTable[0]);
- for (int i = 0; i < len; ++i) {
- if (u == combiningTable[i].base)
- return combiningTable[i].comb;
+ for (const CombiningTable &combining : combiningTable) {
+ if (u == combining.base)
+ return combining.comb;
}
return 0;
}
More information about the poppler
mailing list