Removed not used time consuming calculation of row count from RetroCursor.

This commit is contained in:
thunder2 2015-09-07 22:27:04 +02:00
parent 29a1fa2ce4
commit c4061fc6aa
3 changed files with 11 additions and 64 deletions

View File

@ -1146,10 +1146,6 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
if(c)
{
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0);
#ifdef RS_DATA_SERVICE_DEBUG_TIME
resultCount += msgSet.size();
#endif
}
delete c;
@ -1169,16 +1165,16 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
if(c)
{
locked_retrieveMessages(c, msgSet, withMeta ? mColMsg_WithMetaOffset : 0);
#ifdef RS_DATA_SERVICE_DEBUG_TIME
resultCount += c->getResultCount();
#endif
}
delete c;
}
}
#ifdef RS_DATA_SERVICE_DEBUG_TIME
resultCount += msgSet.size();
#endif
msg[grpId] = msgSet;
msgSet.clear();
@ -1235,10 +1231,6 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
if (c)
{
locked_retrieveMsgMeta(c, metaSet);
#ifdef RS_DATA_SERVICE_DEBUG_TIME
resultCount += metaSet.size();
#endif
}
}else{
@ -1253,14 +1245,14 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
if (c)
{
locked_retrieveMsgMeta(c, metaSet);
#ifdef RS_DATA_SERVICE_DEBUG_TIME
resultCount += c->getResultCount();
#endif
}
}
}
#ifdef RS_DATA_SERVICE_DEBUG_TIME
resultCount += metaSet.size();
#endif
msgMeta[grpId] = metaSet;
}

View File

@ -598,7 +598,7 @@ bool RetroDb::tableExists(const std::string &tableName)
/********************** RetroCursor ************************/
RetroCursor::RetroCursor(sqlite3_stmt *stmt)
: mStmt(NULL), mCount(0), mPosCounter(0) {
: mStmt(NULL) {
open(stmt);
}
@ -635,7 +635,6 @@ bool RetroCursor::moveToFirst(){
rc = sqlite3_step(mStmt);
if(rc == SQLITE_ROW){
mPosCounter = 0;
return true;
}
@ -673,17 +672,10 @@ bool RetroCursor::moveToLast(){
return false;
}else{
mPosCounter = mCount;
return true;
}
}
int RetroCursor::getResultCount() const {
if(isOpen())
return mCount;
else
return -1;
}
int RetroCursor::columnCount() const {
if(isOpen())
@ -704,8 +696,6 @@ bool RetroCursor::close(){
int rc = sqlite3_finalize(mStmt);
mStmt = NULL;
mPosCounter = 0;
mCount = 0;
return (rc == SQLITE_OK);
}
@ -725,12 +715,6 @@ bool RetroCursor::open(sqlite3_stmt *stm){
int rc = sqlite3_reset(mStmt);
if(rc == SQLITE_OK){
while((rc = sqlite3_step(mStmt)) == SQLITE_ROW)
mCount++;
sqlite3_reset(mStmt);
return true;
}
else{
@ -753,7 +737,6 @@ bool RetroCursor::moveToNext(){
int rc = sqlite3_step(mStmt);
if(rc == SQLITE_ROW){
mPosCounter++;
return true;
}else if(rc == SQLITE_DONE){ // no more results
@ -772,16 +755,6 @@ bool RetroCursor::moveToNext(){
}
}
int32_t RetroCursor::getPosition() const {
if(isOpen())
return mPosCounter;
else
return -1;
}
int32_t RetroCursor::getInt32(int columnIndex){
return sqlite3_column_int(mStmt, columnIndex);
}

View File

@ -239,12 +239,6 @@ public:
*/
bool moveToLast();
/*!
* gets current position of cursor
* @return current position of cursor
*/
int32_t getPosition() const;
/* data retrieval */
/*!
@ -260,11 +254,10 @@ public:
/*!
*
* @return -1 if cursor is in error, otherwise number of rows in result
* @return -1 if cursor is in error, otherwise number of columns in result
*/
int32_t getResultCount() const;
int32_t columnCount() const ;
/*!
* Current statement is closed and discarded (finalised)
* before actual opening occurs
@ -274,8 +267,6 @@ public:
bool open(sqlite3_stmt* stm);
public:
/*!
* Returns the value of the requested column as a String.
* @param columnIndex the zero-based index of the target column.
@ -326,17 +317,8 @@ public:
getString(columnIndex, temp);
str = T(temp);
}
private:
sqlite3_stmt* mStmt;
int mCount; /// number of results
int mPosCounter;
};
#endif // RSSQLITE_H