summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-01-08 12:30:15 +0800
committerPeng Wu <alexepico@gmail.com>2016-01-08 12:30:15 +0800
commitc253c4fcbf2a9b49224a825f5e5dcffcb412d0a0 (patch)
tree5bdb198069eed60c52eb1651c997cbc90f35b1e1 /src
parent5f84a89a63a572a7c1b7139c3658ea04ce6d16ba (diff)
downloadlibpinyin-c253c4fcbf2a9b49224a825f5e5dcffcb412d0a0.tar.gz
libpinyin-c253c4fcbf2a9b49224a825f5e5dcffcb412d0a0.tar.xz
libpinyin-c253c4fcbf2a9b49224a825f5e5dcffcb412d0a0.zip
refactor code
Diffstat (limited to 'src')
-rw-r--r--src/storage/pinyin_phrase2.h34
-rw-r--r--src/storage/pinyin_phrase3.h66
2 files changed, 66 insertions, 34 deletions
diff --git a/src/storage/pinyin_phrase2.h b/src/storage/pinyin_phrase2.h
index e07371f..fab19c7 100644
--- a/src/storage/pinyin_phrase2.h
+++ b/src/storage/pinyin_phrase2.h
@@ -29,40 +29,6 @@
namespace pinyin{
-inline int pinyin_exact_compare2(const ChewingKey * key_lhs,
- const ChewingKey * key_rhs,
- int phrase_length){
- int i;
- int result;
-
- /* compare initial */
- for (i = 0; i < phrase_length; ++i) {
- result = key_lhs[i].m_initial - key_rhs[i].m_initial;
- if (0 != result)
- return result;
- }
-
- /* compare middle and final */
- for (i = 0; i < phrase_length; ++i) {
- result = key_lhs[i].m_middle - key_rhs[i].m_middle;
- if (0 != result)
- return result;
- result = key_lhs[i].m_final - key_rhs[i].m_final;
- if (0 != result)
- return result;
- }
-
- /* compare tone */
- for (i = 0; i < phrase_length; ++i) {
- result = key_lhs[i].m_tone - key_rhs[i].m_tone;
- if (0 != result)
- return result;
- }
-
- return 0;
-}
-
-
/* compare pinyins with chewing internal representations. */
inline int pinyin_compare_initial2(pinyin_option_t options,
ChewingInitial lhs,
diff --git a/src/storage/pinyin_phrase3.h b/src/storage/pinyin_phrase3.h
new file mode 100644
index 0000000..b99bc15
--- /dev/null
+++ b/src/storage/pinyin_phrase3.h
@@ -0,0 +1,66 @@
+/*
+ * libpinyin
+ * Library to deal with pinyin.
+ *
+ * Copyright (C) 2016 Peng Wu <alexepico@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PINYIN_PHRASE3_H
+#define PINYIN_PHRASE3_H
+
+#include "novel_types.h"
+#include "chewing_key.h"
+
+namespace pinyin{
+
+inline int pinyin_exact_compare2(const ChewingKey * key_lhs,
+ const ChewingKey * key_rhs,
+ int phrase_length){
+ int i;
+ int result;
+
+ /* compare initial */
+ for (i = 0; i < phrase_length; ++i) {
+ result = key_lhs[i].m_initial - key_rhs[i].m_initial;
+ if (0 != result)
+ return result;
+ }
+
+ /* compare middle and final */
+ for (i = 0; i < phrase_length; ++i) {
+ result = key_lhs[i].m_middle - key_rhs[i].m_middle;
+ if (0 != result)
+ return result;
+ result = key_lhs[i].m_final - key_rhs[i].m_final;
+ if (0 != result)
+ return result;
+ }
+
+ /* compare tone */
+ for (i = 0; i < phrase_length; ++i) {
+ result = key_lhs[i].m_tone - key_rhs[i].m_tone;
+ if (0 != result)
+ return result;
+ }
+
+ return 0;
+}
+
+
+};
+
+#endif