[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/sdk/kdevplatform/language/duchain
From:       Milian Wolff <mail () milianw ! de>
Date:       2010-02-28 13:41:46
Message-ID: 1267364506.384255.28994.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1097116 by mwolff:

introduce static lengthFromIndex function - no need for the overhead of IndexedString \
if we just need the length

 M  +7 -3      indexedstring.cpp  
 M  +3 -0      indexedstring.h  


--- trunk/extragear/sdk/kdevplatform/language/duchain/indexedstring.cpp \
#1097115:1097116 @@ -271,12 +271,16 @@
 }
 
 int IndexedString::length() const {
-  if(!m_index)
+  return lengthFromIndex(m_index);
+}
+
+int IndexedString::lengthFromIndex(unsigned int index) {
+  if(!index)
     return 0;
-  else if((m_index & 0xffff0000) == 0xffff0000)
+  else if((index & 0xffff0000) == 0xffff0000)
     return 1;
   else
-    return getGlobalIndexedStringRepository()->itemFromIndex(m_index)->length;
+    return getGlobalIndexedStringRepository()->itemFromIndex(index)->length;
 }
 
 const char* IndexedString::c_str() const
--- trunk/extragear/sdk/kdevplatform/language/duchain/indexedstring.h \
#1097115:1097116 @@ -69,6 +69,9 @@
     return ret;
   }
 
+  //This is relatively expensive(needs a mutex lock, hash lookups, and eventual \
loading), so avoid it when possible. +  static int lengthFromIndex(unsigned int \
index); +
   IndexedString( const IndexedString& );
 
   ~IndexedString();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic