aboutsummaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-02-05 17:38:30 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-02-05 17:38:30 -0800
commita27cb623901d79be1007b0803898086a12ce731b (patch)
treed75deaf2899b9f112ab56a63b7d04b8e941e7272 /native/src
parent3f8fc4de9ae8720a16458198d268dcf7423c1e51 (diff)
parent09baa36f7d1298e54a291b0d486cf366a3c3257c (diff)
downloadlatinime-a27cb623901d79be1007b0803898086a12ce731b.tar.gz
latinime-a27cb623901d79be1007b0803898086a12ce731b.tar.xz
latinime-a27cb623901d79be1007b0803898086a12ce731b.zip
Merge "Use C++ template for min/max"
Diffstat (limited to 'native/src')
-rw-r--r--native/src/correction.cpp1
-rw-r--r--native/src/defines.h4
-rw-r--r--native/src/words_priority_queue.h4
3 files changed, 6 insertions, 3 deletions
diff --git a/native/src/correction.cpp b/native/src/correction.cpp
index 2fc0569fa..4df1c4efb 100644
--- a/native/src/correction.cpp
+++ b/native/src/correction.cpp
@@ -24,6 +24,7 @@
#include "char_utils.h"
#include "correction.h"
+#include "defines.h"
#include "dictionary.h"
#include "proximity_info.h"
diff --git a/native/src/defines.h b/native/src/defines.h
index 1e108cb17..5b5c54850 100644
--- a/native/src/defines.h
+++ b/native/src/defines.h
@@ -241,8 +241,8 @@ static void prof_out(void) {
#define MIN_USER_TYPED_LENGTH_FOR_MULTIPLE_WORD_SUGGESTION 3
#define MIN_USER_TYPED_LENGTH_FOR_EXCESSIVE_CHARACTER_SUGGESTION 3
-#define min(a,b) ((a)<(b)?(a):(b))
-#define max(a,b) ((a)>(b)?(a):(b))
+template<typename T> inline T min(T a, T b) { return a < b ? a : b; }
+template<typename T> inline T max(T a, T b) { return a > b ? a : b; }
// The ratio of neutral area radius to sweet spot radius.
#define NEUTRAL_AREA_RADIUS_RATIO 1.3f
diff --git a/native/src/words_priority_queue.h b/native/src/words_priority_queue.h
index e8cd983b1..249962eec 100644
--- a/native/src/words_priority_queue.h
+++ b/native/src/words_priority_queue.h
@@ -17,6 +17,7 @@
#ifndef LATINIME_WORDS_PRIORITY_QUEUE_H
#define LATINIME_WORDS_PRIORITY_QUEUE_H
+#include <cstring> // for memcpy()
#include <iostream>
#include <queue>
#include "defines.h"
@@ -93,7 +94,8 @@ class WordsPriorityQueue {
int outputSuggestions(int *frequencies, unsigned short *outputChars) {
mHighestSuggestedWord = 0;
- const unsigned int size = min(MAX_WORDS, mSuggestions.size());
+ const unsigned int size = min(
+ MAX_WORDS, static_cast<unsigned int>(mSuggestions.size()));
int index = size - 1;
while (!mSuggestions.empty() && index >= 0) {
SuggestedWord* sw = mSuggestions.top();