diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
index 5ba57f5..f0be0ee 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
@@ -31,15 +31,18 @@
     private int mLastPointX;
     private int mLastPointY;
 
-    private int mMinGestureLength;
-    private int mMinGestureSampleLength;
+    private int mMinGestureLength; // pixel
+    private int mMinGestureSampleLength; // pixel
+    private int mGestureRecognitionThreshold; // pixel / sec
 
     // TODO: Move some of these to resource.
     private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 0.75f;
     private static final int MIN_GESTURE_START_DURATION = 100; // msec
     private static final int MIN_GESTURE_RECOGNITION_TIME = 100; // msec
     private static final float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH = 1.0f / 6.0f;
-    private static final float GESTURE_RECOG_SPEED_THRESHOLD = 0.4f; // dip/msec
+    private static final float GESTURE_RECOGNITION_SPEED_THRESHOLD_RATIO_TO_KEY_WIDTH =
+            5.5f; // keyWidth / sec
+    private static final int MSEC_PER_SEC = 1000;
 
     public static final boolean hasRecognitionTimePast(
             final long currentTime, final long lastRecognitionTime) {
@@ -54,6 +57,8 @@
         // TODO: Find an appropriate base metric for these length. Maybe diagonal length of the key?
         mMinGestureLength = (int)(keyWidth * MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH);
         mMinGestureSampleLength = (int)(keyWidth * MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH);
+        mGestureRecognitionThreshold =
+                (int)(keyWidth * GESTURE_RECOGNITION_SPEED_THRESHOLD_RATIO_TO_KEY_WIDTH);
     }
 
     public boolean isStartOfAGesture() {
@@ -72,47 +77,43 @@
         mYCoordinates.setLength(0);
     }
 
-    private void updateLastPoint(final int x, final int y, final int time) {
+    public void addPoint(final int x, final int y, final int time, final boolean isHistorical) {
+        final boolean needsSampling;
+        final int size = mEventTimes.getLength();
+        if (size == 0) {
+            needsSampling = true;
+        } else {
+            final int lastIndex = size - 1;
+            final int lastX = mXCoordinates.get(lastIndex);
+            final int lastY = mYCoordinates.get(lastIndex);
+            final float dist = getDistance(lastX, lastY, x, y);
+            needsSampling = dist > mMinGestureSampleLength;
+            mLength += dist;
+        }
+        if (needsSampling) {
+            mEventTimes.add(time);
+            mXCoordinates.add(x);
+            mYCoordinates.add(y);
+        }
+        if (!isHistorical) {
+            updateIncrementalRecognitionSize(x, y, time);
+        }
+    }
+
+    private void updateIncrementalRecognitionSize(final int x, final int y, final int time) {
+        final int msecs = (int)(time - mLastPointTime);
+        if (msecs > 0) {
+            final int pixels = (int)getDistance(mLastPointX, mLastPointY, x, y);
+            // Equivalent to (pixels / msecs < mGestureRecognitionThreshold / MSEC_PER_SEC)
+            if (pixels * MSEC_PER_SEC < mGestureRecognitionThreshold * msecs) {
+                mIncrementalRecognitionSize = mEventTimes.getLength();
+            }
+        }
         mLastPointTime = time;
         mLastPointX = x;
         mLastPointY = y;
     }
 
-    public void addPoint(final int x, final int y, final int time, final boolean isHistorical) {
-        final int size = mEventTimes.getLength();
-        if (size == 0) {
-            mEventTimes.add(time);
-            mXCoordinates.add(x);
-            mYCoordinates.add(y);
-            if (!isHistorical) {
-                updateLastPoint(x, y, time);
-            }
-            return;
-        }
-
-        final int lastX = mXCoordinates.get(size - 1);
-        final int lastY = mYCoordinates.get(size - 1);
-        final float dist = getDistance(lastX, lastY, x, y);
-        if (dist > mMinGestureSampleLength) {
-            mEventTimes.add(time);
-            mXCoordinates.add(x);
-            mYCoordinates.add(y);
-            mLength += dist;
-        }
-
-        if (!isHistorical) {
-            final int duration = (int)(time - mLastPointTime);
-            if (mLastPointTime != 0 && duration > 0) {
-                final float distance = getDistance(mLastPointX, mLastPointY, x, y);
-                final float speed = distance / duration;
-                if (speed < GESTURE_RECOG_SPEED_THRESHOLD) {
-                    mIncrementalRecognitionSize = size;
-                }
-            }
-            updateLastPoint(x, y, time);
-        }
-    }
-
     public void appendAllBatchPoints(final InputPointers out) {
         appendBatchPoints(out, mEventTimes.getLength());
     }
