Read shortcuts as strings in the dictionary.

This has no impact on performance.
Before:
(0)  9.61 (0.01%)
(1)  57514.58 (56.70%)
(2)  10.55 (0.01%)
(3)  10.79 (0.01%)
(4)  133.20 (0.13%)
(5)  43553.87 (42.94%)
(6)  10.03 (0.01%)
(20) 47.20 (0.05%)
Total 101431.47 (sum of others 101289.84)

After:
(0)  10.52 (0.01%)
(1)  56311.16 (56.66%)
(2)  13.40 (0.01%)
(3)  10.98 (0.01%)
(4)  136.72 (0.14%)
(5)  42707.92 (42.97%)
(6)  9.79 (0.01%)
(20) 51.35 (0.05%)
Total 99390.76 (sum of others 99251.84)

The difference is not significant with regard to measure imprecision

Change-Id: I2e4f1ef7a5e99082e67dd27f56cf4fc432bb48fa
diff --git a/native/jni/src/terminal_attributes.h b/native/jni/src/terminal_attributes.h
index 1f98159..9a803cc 100644
--- a/native/jni/src/terminal_attributes.h
+++ b/native/jni/src/terminal_attributes.h
@@ -45,13 +45,19 @@
 
         // Gets the shortcut target itself as a uint16_t string. For parameters and return value
         // see BinaryFormat::getWordAtAddress.
+        // TODO: make the output an uint32_t* to handle the whole unicode range.
         inline int getNextShortcutTarget(const int maxDepth, uint16_t* outWord) {
             const int shortcutFlags = BinaryFormat::getFlagsAndForwardPointer(mDict, &mPos);
             mHasNextShortcutTarget =
                     0 != (shortcutFlags & UnigramDictionary::FLAG_ATTRIBUTE_HAS_NEXT);
-            int shortcutAddress =
-                    BinaryFormat::getAttributeAddressAndForwardPointer(mDict, shortcutFlags, &mPos);
-            return BinaryFormat::getWordAtAddress(mDict, shortcutAddress, maxDepth, outWord);
+            unsigned int i;
+            for (i = 0; i < MAX_WORD_LENGTH_INTERNAL; ++i) {
+                const int charCode = BinaryFormat::getCharCodeAndForwardPointer(mDict, &mPos);
+                if (NOT_A_CHARACTER == charCode) break;
+                outWord[i] = (uint16_t)charCode;
+            }
+            mPos += BinaryFormat::CHARACTER_ARRAY_TERMINATOR_SIZE;
+            return i;
         }
     };
 
@@ -65,12 +71,10 @@
             mDict(dict), mFlags(flags), mStartPos(pos) {
     }
 
-    inline bool isShortcutOnly() const {
-        return 0 != (mFlags & UnigramDictionary::FLAG_IS_SHORTCUT_ONLY);
-    }
-
     inline ShortcutIterator getShortcutIterator() const {
-        return ShortcutIterator(mDict, mStartPos, mFlags);
+        // The size of the shortcuts is stored here so that the whole shortcut chunk can be
+        // skipped quickly, so we ignore it.
+        return ShortcutIterator(mDict, mStartPos + BinaryFormat::SHORTCUT_LIST_SIZE_SIZE, mFlags);
     }
 };
 } // namespace latinime