From 1757d1b1cd4b6cee51e1c169cd7524e576e9ddce Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 21 Apr 2007 22:39:04 +0000 Subject: [PATCH] * operator==(docstring const & l, char const * r): optimized a bit because it showed a lot in profile. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17897 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/docstring.C | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/support/docstring.C b/src/support/docstring.C index 57dbc19768..5e9c9a5e7e 100644 --- a/src/support/docstring.C +++ b/src/support/docstring.C @@ -148,15 +148,16 @@ docstring const normalize_kc(docstring const & s) bool operator==(lyx::docstring const & l, char const * r) { - int const len = l.length(); - for (int i = 0; i < len; ++i) { - BOOST_ASSERT(static_cast(r[i]) < 0x80); - if (!r[i]) + lyx::docstring::const_iterator it = l.begin(); + lyx::docstring::const_iterator end = l.end(); + for (; it != end; ++it, ++r) { + BOOST_ASSERT(static_cast(*r) < 0x80); + if (!*r) return false; - if (l[i] != lyx::docstring::value_type(r[i])) + if (*it != static_cast(*r)) return false; } - return r[len] == '\0'; + return *r == '\0'; } -- 2.39.2