From 6cee61deebd0ca2b85054ccc239523d1e5fdfab1 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Tue, 15 Jan 2013 16:15:48 +0900 Subject: [PATCH] Use -fno-inline for debug builds & small cleanups Change-Id: I24f91d7130f2203715b868d4a82510660939886f --- native/jni/Android.mk | 4 ++-- native/jni/src/correction.cpp | 2 ++ native/jni/src/defines.h | 15 ++++++++++----- native/jni/src/geometry_utils.h | 15 +-------------- native/jni/src/proximity_info.cpp | 2 +- native/jni/src/proximity_info_state.cpp | 1 + native/jni/src/proximity_info_state.h | 1 - 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/native/jni/Android.mk b/native/jni/Android.mk index 75f85b120..f2aebd55d 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -66,11 +66,11 @@ LOCAL_SRC_FILES := \ ifeq ($(FLAG_DO_PROFILE), true) $(warning Making profiling version of native library) - LOCAL_CFLAGS += -DFLAG_DO_PROFILE -funwind-tables + LOCAL_CFLAGS += -DFLAG_DO_PROFILE -funwind-tables -fno-inline else # FLAG_DO_PROFILE ifeq ($(FLAG_DBG), true) $(warning Making debug version of native library) - LOCAL_CFLAGS += -DFLAG_DBG -funwind-tables + LOCAL_CFLAGS += -DFLAG_DBG -funwind-tables -fno-inline ifeq ($(FLAG_FULL_DBG), true) $(warning Making full debug version of native library) LOCAL_CFLAGS += -DFLAG_FULL_DBG diff --git a/native/jni/src/correction.cpp b/native/jni/src/correction.cpp index afeda4849..5f630f033 100644 --- a/native/jni/src/correction.cpp +++ b/native/jni/src/correction.cpp @@ -16,6 +16,8 @@ #define LOG_TAG "LatinIME: correction.cpp" +#include + #include "char_utils.h" #include "correction.h" #include "defines.h" diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h index 4e0c57043..c89a870b9 100644 --- a/native/jni/src/defines.h +++ b/native/jni/src/defines.h @@ -23,6 +23,11 @@ #define AK_FORCE_INLINE inline #endif // __GNUC__ +#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG) +#undef AK_FORCE_INLINE +#define AK_FORCE_INLINE inline +#endif // defined(FLAG_DO_PROFILE) || defined(FLAG_DBG) + // Must be identical to Constants.Dictionary.MAX_WORD_LENGTH in Java #define MAX_WORD_LENGTH 48 // Must be identical to BinaryDictionary.MAX_RESULTS in Java @@ -32,7 +37,7 @@ #include #ifndef LOG_TAG #define LOG_TAG "LatinIME: " -#endif +#endif // LOG_TAG #define AKLOGE(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, fmt, ##__VA_ARGS__) #define AKLOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, fmt, ##__VA_ARGS__) @@ -110,14 +115,14 @@ static inline void showStackTrace() { } free(strs); } -#else +#else // __ANDROID__ #include #define DO_ASSERT_TEST #define ASSERT(success) assert(success) #define SHOW_STACK_TRACE -#endif +#endif // __ANDROID__ -#else +#else // defined(FLAG_DO_PROFILE) || defined(FLAG_DBG) #define AKLOGE(fmt, ...) #define AKLOGI(fmt, ...) #define DUMP_RESULT(words, frequencies) @@ -126,7 +131,7 @@ static inline void showStackTrace() { #define ASSERT(success) #define SHOW_STACK_TRACE #define INTS_TO_CHARS(input, length, output) -#endif +#endif // defined(FLAG_DO_PROFILE) || defined(FLAG_DBG) #ifdef FLAG_DO_PROFILE // Profiler diff --git a/native/jni/src/geometry_utils.h b/native/jni/src/geometry_utils.h index 4060a7bd3..4bff80f15 100644 --- a/native/jni/src/geometry_utils.h +++ b/native/jni/src/geometry_utils.h @@ -21,8 +21,6 @@ #include "defines.h" -#define DEBUG_DECODER false - #define M_PI_F 3.14159265f #define ROUND_FLOAT_10000(f) ((f) < 1000.0f && (f) > 0.001f) \ ? (floorf((f) * 10000.0f) / 10000.0f) : (f) @@ -36,19 +34,8 @@ static inline float getSquaredDistanceFloat(const float x1, const float y1, cons return SQUARE_FLOAT(x1 - x2) + SQUARE_FLOAT(y1 - y2); } -static inline float getNormalizedSquaredDistanceFloat(const float x1, const float y1, - const float x2, const float y2, const float scale) { - return getSquaredDistanceFloat(x1, y1, x2, y2) / SQUARE_FLOAT(scale); -} - -static inline float getDistanceFloat(const float x1, const float y1, const float x2, - const float y2) { - return hypotf(x1 - x2, y1 - y2); -} - static AK_FORCE_INLINE int getDistanceInt(const int x1, const int y1, const int x2, const int y2) { - return static_cast(getDistanceFloat(static_cast(x1), static_cast(y1), - static_cast(x2), static_cast(y2))); + return static_cast(hypotf(static_cast(x1 - x2), static_cast(y1 - y2))); } static AK_FORCE_INLINE float getAngle(const int x1, const int y1, const int x2, const int y2) { diff --git a/native/jni/src/proximity_info.cpp b/native/jni/src/proximity_info.cpp index 8ad9c77dc..9b99554d6 100644 --- a/native/jni/src/proximity_info.cpp +++ b/native/jni/src/proximity_info.cpp @@ -144,7 +144,7 @@ float ProximityInfo::getNormalizedSquaredDistanceFromCenterFloatG( const float touchX = static_cast(x); const float touchY = static_cast(y); const float keyWidth = static_cast(getMostCommonKeyWidth()); - return getNormalizedSquaredDistanceFloat(centerX, centerY, touchX, touchY, keyWidth); + return getSquaredDistanceFloat(centerX, centerY, touchX, touchY) / SQUARE_FLOAT(keyWidth); } int ProximityInfo::squaredDistanceToEdge(const int keyId, const int x, const int y) const { diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp index 2e89e9ad9..d0cc4acc2 100644 --- a/native/jni/src/proximity_info_state.cpp +++ b/native/jni/src/proximity_info_state.cpp @@ -20,6 +20,7 @@ #define LOG_TAG "LatinIME: proximity_info_state.cpp" #include "defines.h" +#include "geometry_utils.h" #include "proximity_info.h" #include "proximity_info_state.h" diff --git a/native/jni/src/proximity_info_state.h b/native/jni/src/proximity_info_state.h index 49c33e544..c8d417dd0 100644 --- a/native/jni/src/proximity_info_state.h +++ b/native/jni/src/proximity_info_state.h @@ -24,7 +24,6 @@ #include "char_utils.h" #include "defines.h" -#include "geometry_utils.h" #include "hash_map_compat.h" namespace latinime {