Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e348e24 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "@FastNative for CursorWindow"

parents 5df8db67 0834e356
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.util.Log;
import android.util.LongSparseArray;
import android.util.SparseIntArray;

import dalvik.annotation.optimization.FastNative;
import dalvik.system.CloseGuard;

/**
@@ -62,28 +63,43 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
    private static native void nativeDispose(long windowPtr);
    private static native void nativeWriteToParcel(long windowPtr, Parcel parcel);

    private static native String nativeGetName(long windowPtr);
    private static native byte[] nativeGetBlob(long windowPtr, int row, int column);
    private static native String nativeGetString(long windowPtr, int row, int column);
    private static native void nativeCopyStringToBuffer(long windowPtr, int row, int column,
            CharArrayBuffer buffer);
    private static native boolean nativePutBlob(long windowPtr, byte[] value, int row, int column);
    private static native boolean nativePutString(long windowPtr, String value,
            int row, int column);

    // Below native methods don't do unconstrained work, so are FastNative for performance

    @FastNative
    private static native void nativeClear(long windowPtr);

    @FastNative
    private static native int nativeGetNumRows(long windowPtr);
    @FastNative
    private static native boolean nativeSetNumColumns(long windowPtr, int columnNum);
    @FastNative
    private static native boolean nativeAllocRow(long windowPtr);
    @FastNative
    private static native void nativeFreeLastRow(long windowPtr);

    @FastNative
    private static native int nativeGetType(long windowPtr, int row, int column);
    private static native byte[] nativeGetBlob(long windowPtr, int row, int column);
    private static native String nativeGetString(long windowPtr, int row, int column);
    @FastNative
    private static native long nativeGetLong(long windowPtr, int row, int column);
    @FastNative
    private static native double nativeGetDouble(long windowPtr, int row, int column);
    private static native void nativeCopyStringToBuffer(long windowPtr, int row, int column,
            CharArrayBuffer buffer);

    private static native boolean nativePutBlob(long windowPtr, byte[] value, int row, int column);
    private static native boolean nativePutString(long windowPtr, String value, int row, int column);
    @FastNative
    private static native boolean nativePutLong(long windowPtr, long value, int row, int column);
    @FastNative
    private static native boolean nativePutDouble(long windowPtr, double value, int row, int column);
    @FastNative
    private static native boolean nativePutNull(long windowPtr, int row, int column);

    private static native String nativeGetName(long windowPtr);

    /**
     * Creates a new empty cursor window and gives it a name.
+14 −10
Original line number Diff line number Diff line
@@ -519,8 +519,21 @@ static const JNINativeMethod sMethods[] =
            (void*)nativeDispose },
    { "nativeWriteToParcel", "(JLandroid/os/Parcel;)V",
            (void*)nativeWriteToParcel },

    { "nativeGetName", "(J)Ljava/lang/String;",
            (void*)nativeGetName },
    { "nativeGetBlob", "(JII)[B",
            (void*)nativeGetBlob },
    { "nativeGetString", "(JII)Ljava/lang/String;",
            (void*)nativeGetString },
    { "nativeCopyStringToBuffer", "(JIILandroid/database/CharArrayBuffer;)V",
            (void*)nativeCopyStringToBuffer },
    { "nativePutBlob", "(J[BII)Z",
            (void*)nativePutBlob },
    { "nativePutString", "(JLjava/lang/String;II)Z",
            (void*)nativePutString },

    // ------- @FastNative below here ----------------------
    { "nativeClear", "(J)V",
            (void*)nativeClear },
    { "nativeGetNumRows", "(J)I",
@@ -533,20 +546,11 @@ static const JNINativeMethod sMethods[] =
            (void*)nativeFreeLastRow },
    { "nativeGetType", "(JII)I",
            (void*)nativeGetType },
    { "nativeGetBlob", "(JII)[B",
            (void*)nativeGetBlob },
    { "nativeGetString", "(JII)Ljava/lang/String;",
            (void*)nativeGetString },
    { "nativeGetLong", "(JII)J",
            (void*)nativeGetLong },
    { "nativeGetDouble", "(JII)D",
            (void*)nativeGetDouble },
    { "nativeCopyStringToBuffer", "(JIILandroid/database/CharArrayBuffer;)V",
            (void*)nativeCopyStringToBuffer },
    { "nativePutBlob", "(J[BII)Z",
            (void*)nativePutBlob },
    { "nativePutString", "(JLjava/lang/String;II)Z",
            (void*)nativePutString },

    { "nativePutLong", "(JJII)Z",
            (void*)nativePutLong },
    { "nativePutDouble", "(JDII)Z",