summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-13 02:22:58 (UTC)
committer zecke <zecke>2002-10-13 02:22:58 (UTC)
commitd96ce086c617b5b2efc5081cd10a43257a78f488 (patch) (unidiff)
tree4f6b80b7295127bd82cc5fb8ffd1d532c42a396b
parent2ce86d9be1bbf99092348adf815578b110fe7289 (diff)
downloadopie-d96ce086c617b5b2efc5081cd10a43257a78f488.zip
opie-d96ce086c617b5b2efc5081cd10a43257a78f488.tar.gz
opie-d96ce086c617b5b2efc5081cd10a43257a78f488.tar.bz2
OPimAccessBackend nothing tried a isDirty()const ... but removed it
ORecordList uidAt(uint index ) added Speed Improvements at the SQL backend do not load the list of uids until it's really needed do not reload the uid list until it's really needed we got a bitfield m_dirty there...
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/opimaccesstemplate.h2
-rw-r--r--libopie/pim/orecordlist.h5
-rw-r--r--libopie/pim/otodoaccesssql.cpp31
-rw-r--r--libopie/pim/otodoaccesssql.h3
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp31
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h3
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h2
-rw-r--r--libopie2/opiepim/orecordlist.h5
8 files changed, 58 insertions, 24 deletions
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index 92d7192..a0d8f63 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -186,3 +186,2 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
186 if (m_cache.contains( uid ) ) { 186 if (m_cache.contains( uid ) ) {
187 qWarning("m cache contains %d", uid);
188 return m_cache.find( uid ); 187 return m_cache.find( uid );
@@ -191,3 +190,2 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
191 T t = m_backEnd->find( uid, ar, current, dir ); 190 T t = m_backEnd->find( uid, ar, current, dir );
192 qWarning("found it and cache it now %d", uid);
193 cache( t ); 191 cache( t );
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index 08f5c85..5404910 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -111,2 +111,3 @@ public:
111 T operator[]( uint i ); 111 T operator[]( uint i );
112 int uidAt(uint i );
112 // FIXME implemenent remove 113 // FIXME implemenent remove
@@ -264,2 +265,6 @@ T ORecordList<T>::operator[]( uint i ) {
264} 265}
266template <class T>
267int ORecordList<T>::uidAt( uint i ) {
268 return m_ids[i];
269}
265#endif 270#endif
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp
index a059dab..ea8b3c9 100644
--- a/libopie/pim/otodoaccesssql.cpp
+++ b/libopie/pim/otodoaccesssql.cpp
@@ -243,3 +243,3 @@ namespace {
243OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) 243OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file )
244 : OTodoAccessBackend(), m_dict(15) 244 : OTodoAccessBackend(), m_dict(15), m_dirty(true)
245{ 245{
@@ -263,4 +263,3 @@ bool OTodoAccessBackendSQL::load(){
263 263
264 update(); 264 m_dirty = true;
265 qWarning("loaded %d", m_uids.count() );
266 return true; 265 return true;
@@ -275,2 +274,5 @@ bool OTodoAccessBackendSQL::save(){
275QArray<int> OTodoAccessBackendSQL::allRecords()const { 274QArray<int> OTodoAccessBackendSQL::allRecords()const {
275 if (m_dirty )
276 update();
277
276 return m_uids; 278 return m_uids;
@@ -305,3 +307,3 @@ OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
305 case 1: 307 case 1:
306 for (uint i = cur; i >= 0 && size < 8; i-- ) { 308 for (uint i = cur; i != 0 && size < 8; i-- ) {
307 search[size] = ints[i]; 309 search[size] = ints[i];
@@ -344,3 +346,3 @@ bool OTodoAccessBackendSQL::remove( int uid ) {
344 346
345 update(); 347 m_dirty = true;
346 return true; 348 return true;
@@ -354,3 +356,5 @@ bool OTodoAccessBackendSQL::replace( const OTodo& t) {
354 remove( t.uid() ); 356 remove( t.uid() );
355 return add(t); 357 bool b= add(t);
358 m_dirty = false; // we changed some stuff but the UID stayed the same
359 return b;
356} 360}
@@ -371,2 +375,3 @@ QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
371 int sortFilter, int cat ) { 375 int sortFilter, int cat ) {
376 qWarning("sorted %d, %d", asc, sortOrder );
372 QString query; 377 QString query;
@@ -423,4 +428,7 @@ QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
423 } 428 }
424 if ( !asc ) 429
430 if ( !asc ) {
431 qWarning("not ascending!");
425 query += " DESC"; 432 query += " DESC";
433 }
426 434
@@ -503,3 +511,8 @@ void OTodoAccessBackendSQL::fillDict() {
503} 511}
504void OTodoAccessBackendSQL::update() { 512/*
513 * need to be const so let's fool the
514 * compiler :(
515 */
516void OTodoAccessBackendSQL::update()const {
517 ((OTodoAccessBackendSQL*)this)->m_dirty = false;
505 LoadQuery lo; 518 LoadQuery lo;
@@ -509,3 +522,3 @@ void OTodoAccessBackendSQL::update() {
509 522
510 m_uids = uids( res ); 523 ((OTodoAccessBackendSQL*)this)->m_uids = uids( res );
511} 524}
diff --git a/libopie/pim/otodoaccesssql.h b/libopie/pim/otodoaccesssql.h
index c1aa2ed..0f6dd2c 100644
--- a/libopie/pim/otodoaccesssql.h
+++ b/libopie/pim/otodoaccesssql.h
@@ -34,3 +34,3 @@ public:
34private: 34private:
35 void update(); 35 void update()const;
36 void fillDict(); 36 void fillDict();
@@ -45,2 +45,3 @@ private:
45 QArray<int> m_uids; 45 QArray<int> m_uids;
46 bool m_dirty : 1;
46}; 47};
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index a059dab..ea8b3c9 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -243,3 +243,3 @@ namespace {
243OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) 243OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file )
244 : OTodoAccessBackend(), m_dict(15) 244 : OTodoAccessBackend(), m_dict(15), m_dirty(true)
245{ 245{
@@ -263,4 +263,3 @@ bool OTodoAccessBackendSQL::load(){
263 263
264 update(); 264 m_dirty = true;
265 qWarning("loaded %d", m_uids.count() );
266 return true; 265 return true;
@@ -275,2 +274,5 @@ bool OTodoAccessBackendSQL::save(){
275QArray<int> OTodoAccessBackendSQL::allRecords()const { 274QArray<int> OTodoAccessBackendSQL::allRecords()const {
275 if (m_dirty )
276 update();
277
276 return m_uids; 278 return m_uids;
@@ -305,3 +307,3 @@ OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
305 case 1: 307 case 1:
306 for (uint i = cur; i >= 0 && size < 8; i-- ) { 308 for (uint i = cur; i != 0 && size < 8; i-- ) {
307 search[size] = ints[i]; 309 search[size] = ints[i];
@@ -344,3 +346,3 @@ bool OTodoAccessBackendSQL::remove( int uid ) {
344 346
345 update(); 347 m_dirty = true;
346 return true; 348 return true;
@@ -354,3 +356,5 @@ bool OTodoAccessBackendSQL::replace( const OTodo& t) {
354 remove( t.uid() ); 356 remove( t.uid() );
355 return add(t); 357 bool b= add(t);
358 m_dirty = false; // we changed some stuff but the UID stayed the same
359 return b;
356} 360}
@@ -371,2 +375,3 @@ QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
371 int sortFilter, int cat ) { 375 int sortFilter, int cat ) {
376 qWarning("sorted %d, %d", asc, sortOrder );
372 QString query; 377 QString query;
@@ -423,4 +428,7 @@ QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
423 } 428 }
424 if ( !asc ) 429
430 if ( !asc ) {
431 qWarning("not ascending!");
425 query += " DESC"; 432 query += " DESC";
433 }
426 434
@@ -503,3 +511,8 @@ void OTodoAccessBackendSQL::fillDict() {
503} 511}
504void OTodoAccessBackendSQL::update() { 512/*
513 * need to be const so let's fool the
514 * compiler :(
515 */
516void OTodoAccessBackendSQL::update()const {
517 ((OTodoAccessBackendSQL*)this)->m_dirty = false;
505 LoadQuery lo; 518 LoadQuery lo;
@@ -509,3 +522,3 @@ void OTodoAccessBackendSQL::update() {
509 522
510 m_uids = uids( res ); 523 ((OTodoAccessBackendSQL*)this)->m_uids = uids( res );
511} 524}
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index c1aa2ed..0f6dd2c 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -34,3 +34,3 @@ public:
34private: 34private:
35 void update(); 35 void update()const;
36 void fillDict(); 36 void fillDict();
@@ -45,2 +45,3 @@ private:
45 QArray<int> m_uids; 45 QArray<int> m_uids;
46 bool m_dirty : 1;
46}; 47};
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 92d7192..a0d8f63 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -186,3 +186,2 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
186 if (m_cache.contains( uid ) ) { 186 if (m_cache.contains( uid ) ) {
187 qWarning("m cache contains %d", uid);
188 return m_cache.find( uid ); 187 return m_cache.find( uid );
@@ -191,3 +190,2 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
191 T t = m_backEnd->find( uid, ar, current, dir ); 190 T t = m_backEnd->find( uid, ar, current, dir );
192 qWarning("found it and cache it now %d", uid);
193 cache( t ); 191 cache( t );
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 08f5c85..5404910 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -111,2 +111,3 @@ public:
111 T operator[]( uint i ); 111 T operator[]( uint i );
112 int uidAt(uint i );
112 // FIXME implemenent remove 113 // FIXME implemenent remove
@@ -264,2 +265,6 @@ T ORecordList<T>::operator[]( uint i ) {
264} 265}
266template <class T>
267int ORecordList<T>::uidAt( uint i ) {
268 return m_ids[i];
269}
265#endif 270#endif