summaryrefslogtreecommitdiffabout
path: root/kabc/vcard/VCardEntity.cpp
Side-by-side diff
Diffstat (limited to 'kabc/vcard/VCardEntity.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/VCardEntity.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp
index 5fca3bc..b676cc7 100644
--- a/kabc/vcard/VCardEntity.cpp
+++ b/kabc/vcard/VCardEntity.cpp
@@ -68,19 +68,25 @@ VCardEntity::operator == (VCardEntity & x)
x.parse();
return false;
}
VCardEntity::~VCardEntity()
{
}
+#include <qdatetime.h>;
void
VCardEntity::_parse()
{
+#if 0
+ QTime tim;
+ tim.start();
+ int num = 0;
+ // old code
vDebug("parse");
QCString s(strRep_);
int i = s.find(QRegExp("BEGIN:VCARD", false));
while (i != -1) {
i = s.find(QRegExp("BEGIN:VCARD", false), 11);
@@ -90,16 +96,55 @@ VCardEntity::_parse()
VCard * v = new VCard(cardStr);
cardList_.append(v);
v->parse();
s.remove(0, i);
}
+
+#else
+ // this code is up to 17 (!) times faster
+ int start = 0;
+ QTime tim;
+ tim.start();
+ int i = 11;
+ int len = strRep_.length();
+ int num = 0;
+ while (i < len ) {
+ while( i < len ) {
+ int add = 1;
+ if ( strRep_.at(i) == 'B' ) {
+ if ( i+add < len && strRep_.at(i+add++) == 'E')
+ if ( i+add < len && strRep_.at(i+add++) == 'G')
+ if ( i+add < len && strRep_.at(i+add++) == 'I')
+ if ( i+add < len && strRep_.at(i+add++) == 'N')
+ if ( i+add < len && strRep_.at(i+add++) == ':')
+ if ( i+add < len && strRep_.at(i+add++) == 'V')
+ if ( i+add < len && strRep_.at(i+add++) == 'C')
+ if ( i+add < len && strRep_.at(i+add++) == 'A')
+ if ( i+add < len && strRep_.at(i+add++) == 'R')
+ if ( i+add < len && strRep_.at(i+add++) == 'D')
+ break;
+ }
+ ++i;
+ }
+ if ( i <= len ) {
+ ++num;
+ char* dat = strRep_.data()+start;
+ VCard * v = new VCard( QCString ( dat,i-start ) );
+ start = i;
+ cardList_.append(v);
+ v->parse();
+ }
+ i+= 11;
+ }
+#endif
+ //qDebug("***time %d found %d", tim.elapsed(), num);
}
void
VCardEntity::_assemble()
{
VCardListIterator it(cardList_);
for (; it.current(); ++it)