From bd1e9d239f45477be2567a47edd31987ff60e6fd Mon Sep 17 00:00:00 2001 From: Andreas Huggel Date: Fri, 26 Sep 2008 15:20:57 +0000 Subject: [PATCH] Some performance tweaks (analysis by Vladimir Nadvornik) --- src/tags.cpp | 14 +++++++++++--- src/tags.hpp | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/tags.cpp b/src/tags.cpp index 7182049b..54c0d06d 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -47,6 +47,7 @@ EXIV2_RCSID("@(#) $Id$") #include #include #include +#include #ifdef EXV_HAVE_ICONV # include @@ -75,9 +76,11 @@ namespace Exiv2 { return ifdId_ == ifdId; } - bool IfdInfo::operator==(Item item) const + bool IfdInfo::operator==(const Item& item) const { - return std::string(item_) == item.i_; + const char* i = item.i_.c_str(); + if (i == 0) return false; + return (strlen(i) == strlen(item_) && 0 == strcmp(i, item_)); } // Important: IFD item must be unique! @@ -1619,8 +1622,13 @@ namespace Exiv2 { { const TagInfo* ti = tagList(ifdId); if (ti == 0) return 0; + const char* tn = tagName.c_str(); + if (tn == 0) return 0; for (int idx = 0; ti[idx].tag_ != 0xffff; ++idx) { - if (std::string(ti[idx].name_) == tagName) return &ti[idx]; + if ( strlen(ti[idx].name_) == strlen(tn) + && strcmp(ti[idx].name_, tn) == 0) { + return &ti[idx]; + } } return 0; } // ExifTags::tagInfo diff --git a/src/tags.hpp b/src/tags.hpp index 739b23b2..c80d6243 100644 --- a/src/tags.hpp +++ b/src/tags.hpp @@ -76,7 +76,7 @@ namespace Exiv2 { struct EXIV2API IfdInfo { struct Item; bool operator==(IfdId ifdId) const; //!< Comparison operator for IFD id - bool operator==(Item item) const; //!< Comparison operator for IFD item + bool operator==(const Item& item) const; //!< Comparison operator for IFD item IfdId ifdId_; //!< IFD id const char* name_; //!< IFD name const char* item_; //!< Related IFD item. This is also an IFD name, unique for each IFD.