Merge "Fix offdevice build."
diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp
index 10f8d32..d17d2d5 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp
+++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp
@@ -25,6 +25,13 @@
 
 namespace latinime {
 
+/* static */ Ver4DictBuffers::Ver4DictBuffersPtr Ver4DictBuffers::openVer4DictBuffers(
+        const char *const dictDirPath, const MmappedBuffer::MmappedBufferPtr &headerBuffer) {
+    const bool isUpdatable = headerBuffer.get() ? headerBuffer.get()->isUpdatable() : false;
+    // TODO: take only dictDirPath, and open both header and trie files in the constructor below
+    return Ver4DictBuffersPtr(new Ver4DictBuffers(dictDirPath, headerBuffer, isUpdatable));
+}
+
 bool Ver4DictBuffers::flushHeaderAndDictBuffers(const char *const dictDirPath,
         const BufferWithExtendableBuffer *const headerBuffer) const {
     // Create temporary directory.
@@ -91,4 +98,32 @@
     return true;
 }
 
+Ver4DictBuffers::Ver4DictBuffers(const char *const dictDirPath,
+        const MmappedBuffer::MmappedBufferPtr &headerBuffer, const bool isUpdatable)
+        : mHeaderBuffer(headerBuffer),
+          mDictBuffer(MmappedBuffer::openBuffer(dictDirPath,
+                  Ver4DictConstants::TRIE_FILE_EXTENSION, isUpdatable)),
+          mHeaderPolicy(headerBuffer.get()->getBuffer(), FormatUtils::VERSION_4),
+          mExpandableHeaderBuffer(headerBuffer.get()->getBuffer(), mHeaderPolicy.getSize(),
+                  BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
+          mExpandableTrieBuffer(mDictBuffer.get()->getBuffer(),
+                  mDictBuffer.get()->getBufferSize(),
+                  BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
+          mTerminalPositionLookupTable(dictDirPath, isUpdatable),
+          mProbabilityDictContent(dictDirPath, mHeaderPolicy.hasHistoricalInfoOfWords(),
+                  isUpdatable),
+          mBigramDictContent(dictDirPath, mHeaderPolicy.hasHistoricalInfoOfWords(),
+                  isUpdatable),
+          mShortcutDictContent(dictDirPath, isUpdatable),
+          mIsUpdatable(isUpdatable) {}
+
+Ver4DictBuffers::Ver4DictBuffers(const HeaderPolicy *const headerPolicy)
+        : mHeaderBuffer(0), mDictBuffer(0), mHeaderPolicy(),
+          mExpandableHeaderBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),
+          mExpandableTrieBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),
+          mTerminalPositionLookupTable(),
+          mProbabilityDictContent(headerPolicy->hasHistoricalInfoOfWords()),
+          mBigramDictContent(headerPolicy->hasHistoricalInfoOfWords()), mShortcutDictContent(),
+          mIsUpdatable(true) {}
+
 } // namespace latinime
diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.h b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.h
index 8a13671..a0c219e 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.h
+++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.h
@@ -33,12 +33,8 @@
  public:
     typedef ExclusiveOwnershipPointer<Ver4DictBuffers> Ver4DictBuffersPtr;
 
-    static AK_FORCE_INLINE Ver4DictBuffersPtr openVer4DictBuffers(const char *const dictDirPath,
-            const MmappedBuffer::MmappedBufferPtr &headerBuffer) {
-        const bool isUpdatable = headerBuffer.get() ? headerBuffer.get()->isUpdatable() : false;
-        // TODO: take only dictDirPath, and open both header and trie files in the constructor below
-        return Ver4DictBuffersPtr(new Ver4DictBuffers(dictDirPath, headerBuffer, isUpdatable));
-    }
+    static Ver4DictBuffersPtr openVer4DictBuffers(const char *const dictDirPath,
+            const MmappedBuffer::MmappedBufferPtr &headerBuffer);
 
     static AK_FORCE_INLINE Ver4DictBuffersPtr createVer4DictBuffers(
             const HeaderPolicy *const headerPolicy) {
@@ -121,33 +117,10 @@
  private:
     DISALLOW_COPY_AND_ASSIGN(Ver4DictBuffers);
 
-    AK_FORCE_INLINE Ver4DictBuffers(const char *const dictDirPath,
-            const MmappedBuffer::MmappedBufferPtr &headerBuffer, const bool isUpdatable)
-            : mHeaderBuffer(headerBuffer),
-              mDictBuffer(MmappedBuffer::openBuffer(dictDirPath,
-                      Ver4DictConstants::TRIE_FILE_EXTENSION, isUpdatable)),
-              mHeaderPolicy(headerBuffer.get()->getBuffer(), FormatUtils::VERSION_4),
-              mExpandableHeaderBuffer(headerBuffer.get()->getBuffer(), mHeaderPolicy.getSize(),
-                      BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
-              mExpandableTrieBuffer(mDictBuffer.get()->getBuffer(),
-                      mDictBuffer.get()->getBufferSize(),
-                      BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
-              mTerminalPositionLookupTable(dictDirPath, isUpdatable),
-              mProbabilityDictContent(dictDirPath, mHeaderPolicy.hasHistoricalInfoOfWords(),
-                      isUpdatable),
-              mBigramDictContent(dictDirPath, mHeaderPolicy.hasHistoricalInfoOfWords(),
-                      isUpdatable),
-              mShortcutDictContent(dictDirPath, isUpdatable),
-              mIsUpdatable(isUpdatable) {}
+    Ver4DictBuffers(const char *const dictDirPath,
+            const MmappedBuffer::MmappedBufferPtr &headerBuffer, const bool isUpdatable);
 
-    AK_FORCE_INLINE Ver4DictBuffers(const HeaderPolicy *const headerPolicy)
-            : mHeaderBuffer(0), mDictBuffer(0), mHeaderPolicy(),
-              mExpandableHeaderBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),
-              mExpandableTrieBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),
-              mTerminalPositionLookupTable(),
-              mProbabilityDictContent(headerPolicy->hasHistoricalInfoOfWords()),
-              mBigramDictContent(headerPolicy->hasHistoricalInfoOfWords()), mShortcutDictContent(),
-              mIsUpdatable(true) {}
+    Ver4DictBuffers(const HeaderPolicy *const headerPolicy);
 
     const MmappedBuffer::MmappedBufferPtr mHeaderBuffer;
     const MmappedBuffer::MmappedBufferPtr mDictBuffer;
diff --git a/native/jni/src/utils/exclusive_ownership_pointer.h b/native/jni/src/utils/exclusive_ownership_pointer.h
index 6c67df2..617b349 100644
--- a/native/jni/src/utils/exclusive_ownership_pointer.h
+++ b/native/jni/src/utils/exclusive_ownership_pointer.h
@@ -25,22 +25,23 @@
 class ExclusiveOwnershipPointer {
  public:
     // This instance become an owner of the raw pointer.
-    ExclusiveOwnershipPointer(T *const rawPointer)
+    AK_FORCE_INLINE ExclusiveOwnershipPointer(T *const rawPointer)
             : mPointer(rawPointer),
               mSharedOwnerPtr(new (ExclusiveOwnershipPointer<T> *)(this)) {}
 
     // Move the ownership.
-    ExclusiveOwnershipPointer(const ExclusiveOwnershipPointer<T> &pointer)
+    AK_FORCE_INLINE ExclusiveOwnershipPointer(const ExclusiveOwnershipPointer<T> &pointer)
             : mPointer(pointer.mPointer), mSharedOwnerPtr(pointer.mSharedOwnerPtr) {
         transferOwnership(&pointer);
     }
 
-    ~ExclusiveOwnershipPointer() {
+    AK_FORCE_INLINE ~ExclusiveOwnershipPointer() {
         deletePointersIfHavingOwnership();
     }
 
     // Move the ownership.
-    ExclusiveOwnershipPointer<T> &operator=(const ExclusiveOwnershipPointer<T> &pointer) {
+    AK_FORCE_INLINE ExclusiveOwnershipPointer<T> &operator=(
+            const ExclusiveOwnershipPointer<T> &pointer) {
         // Delete pointers when this is an owner of another pointer.
         deletePointersIfHavingOwnership();
         mPointer = pointer.mPointer;
@@ -49,7 +50,7 @@
         return *this;
     }
 
-    T *get() const {
+    AK_FORCE_INLINE T *get() const {
         return mPointer;
     }