summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/storage/pinyin_base.cpp9
-rw-r--r--src/storage/pinyin_phrase.h12
2 files changed, 10 insertions, 11 deletions
diff --git a/src/storage/pinyin_base.cpp b/src/storage/pinyin_base.cpp
index 90a0baa..66587f0 100644
--- a/src/storage/pinyin_base.cpp
+++ b/src/storage/pinyin_base.cpp
@@ -1384,8 +1384,7 @@ int pinyin_compare_initial (const PinyinCustomSettings &custom,
(lhs == PINYIN_He && rhs == PINYIN_Fo)))
)
return 0;
- else if (lhs < rhs) return -1;
- return 1;
+ else return (lhs - rhs);
}
int pinyin_compare_final (const PinyinCustomSettings &custom,
@@ -1407,8 +1406,7 @@ int pinyin_compare_final (const PinyinCustomSettings &custom,
return 0;
else if (custom.use_incomplete && (lhs == PINYIN_ZeroFinal || rhs == PINYIN_ZeroFinal))
return 0;
- else if (lhs < rhs) return -1;
- return 1;
+ else return (lhs - rhs);
}
int pinyin_compare_tone (const PinyinCustomSettings &custom,
@@ -1417,8 +1415,7 @@ int pinyin_compare_tone (const PinyinCustomSettings &custom,
{
if(lhs == rhs || !lhs || !rhs)
return 0;
- else if (lhs < rhs) return -1;
- return 1;
+ else return (lhs - rhs);
}
};
diff --git a/src/storage/pinyin_phrase.h b/src/storage/pinyin_phrase.h
index 25863d2..9ce2c3f 100644
--- a/src/storage/pinyin_phrase.h
+++ b/src/storage/pinyin_phrase.h
@@ -27,6 +27,7 @@
namespace novel{
+/*
static inline int pinyin_utility_sign(int value){
if(value > 0)
return 1;
@@ -34,6 +35,7 @@ static inline int pinyin_utility_sign(int value){
return -1;
else return 0;
}
+*/
inline int pinyin_exact_compare(const PinyinKey key_lhs[],
const PinyinKey key_rhs[],
@@ -43,17 +45,17 @@ inline int pinyin_exact_compare(const PinyinKey key_lhs[],
for ( i = 0 ; i < phrase_length ; i++){
result = key_lhs[i].m_initial - key_rhs[i].m_initial;
if ( result != 0 )
- return pinyin_utility_sign(result);
+ return result;
}
for( i = 0 ; i < phrase_length ; i++){
result = key_lhs[i].m_final - key_rhs[i].m_final;
if ( result != 0 )
- return pinyin_utility_sign(result);
+ return result;
}
for( i = 0 ; i < phrase_length ; i++){
result = key_lhs[i].m_tone - key_rhs[i].m_tone;
if ( result != 0 )
- return pinyin_utility_sign(result);
+ return result;
}
return 0;
}
@@ -269,7 +271,7 @@ class PhraseExactLessThan
public:
bool operator () (const PinyinIndexItem<phrase_length> &lhs,
const PinyinIndexItem<phrase_length> &rhs) const{
- return -1 == m_compare(lhs, rhs);
+ return 0 > m_compare(lhs, rhs);
}
};
@@ -285,7 +287,7 @@ class PhraseExactLessThanWithToken
public:
bool operator () (const PinyinIndexItem<phrase_length> &lhs,
const PinyinIndexItem<phrase_length> &rhs) const{
- return -1 == m_compare(lhs, rhs);
+ return 0 > m_compare(lhs, rhs);
}
};
*/