From: Peng Huang Date: Sat, 10 Apr 2010 12:16:24 +0000 (+0800) Subject: Refine code X-Git-Tag: 1.3.10~245 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35374ff6a33cb02a95c03c3d3a20a62e7217a366;p=platform%2Fupstream%2Fibus-libpinyin.git Refine code --- diff --git a/src/Database.cc b/src/Database.cc index 1332791..c7e1823 100644 --- a/src/Database.cc +++ b/src/Database.cc @@ -85,15 +85,23 @@ public: } gboolean step (void) { - return sqlite3_step (m_stmt) == SQLITE_ROW; + switch (sqlite3_step (m_stmt)) { + case SQLITE_ROW: + return TRUE; + case SQLITE_DONE: + return FALSE; + default: + g_warning ("sqlites step error!"); + return FALSE; + } } - const gchar *columnText (guint i) { - return (const gchar *) sqlite3_column_text (m_stmt, i); + const gchar *columnText (guint col) { + return (const gchar *) sqlite3_column_text (m_stmt, col); } - gint columnInt (guint i) { - return sqlite3_column_int (m_stmt, i); + gint columnInt (guint col) { + return sqlite3_column_int (m_stmt, col); } private: @@ -148,6 +156,7 @@ Query::fill (PhraseArray &phrases, gint count) phrase.pinyin_id[i][0] = m_stmt->columnInt (column++); phrase.pinyin_id[i][1] = m_stmt->columnInt (column++); } + phrases.push_back (phrase); row ++; if (G_UNLIKELY (row == count)) { diff --git a/src/Phrase.h b/src/Phrase.h index 20de45d..02f091f 100644 --- a/src/Phrase.h +++ b/src/Phrase.h @@ -7,10 +7,9 @@ namespace PY { - typedef struct _Phrase Phrase; struct _Phrase { - gchar phrase[(MAX_PHRASE_LEN + 1) * MAX_UTF8_LEN]; + gchar phrase[MAX_UTF8_LEN * (MAX_PHRASE_LEN + 1)]; guint freq; guint user_freq; guint pinyin_id[MAX_PHRASE_LEN][2];