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

Commit 3bc6bbc9 authored by Jeff Brown's avatar Jeff Brown
Browse files

Clean up CursorWindow code.

Bug: 5332296

The code is functionally equivalent, but a little more efficient
and much easier to maintain.

Change-Id: I90670a13799df05831843a5137ab234929281b7c
parent 3b2faf68
Loading
Loading
Loading
Loading
+426 −366

File changed.

Preview size limit exceeded, changes collapsed.

+5 −10
Original line number Diff line number Diff line
@@ -18,17 +18,12 @@ package android.database;

/**
 * This exception is thrown when a CursorWindow couldn't be allocated,
 * most probably due to memory not being available
 * most probably due to memory not being available.
 *
 * @hide
 */
class CursorWindowAllocationException extends java.lang.RuntimeException
{
    public CursorWindowAllocationException()
    {
        super();
    }

    public CursorWindowAllocationException(String description)
    {
public class CursorWindowAllocationException extends RuntimeException {
    public CursorWindowAllocationException(String description) {
        super(description);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public class SQLiteQuery extends SQLiteProgram {
                // if the start pos is not equal to 0, then most likely window is
                // too small for the data set, loading by another thread
                // is not safe in this situation. the native code will ignore maxRead
                int numRows = native_fill_window(window, window.getStartPosition(),
                int numRows = native_fill_window(window.mWindowPtr, window.getStartPosition(),
                        mOffsetIndex, maxRead, lastPos);
                mDatabase.logTimeStat(mSql, timeStart);
                return numRows;
@@ -154,7 +154,7 @@ public class SQLiteQuery extends SQLiteProgram {
        compileAndbindAllArgs();
    }

    private final native int native_fill_window(CursorWindow window,
    private final native int native_fill_window(int windowPtr,
            int startPos, int offsetParam, int maxRead, int lastPos);

    private final native int native_column_count();
+350 −427

File changed.

Preview size limit exceeded, changes collapsed.

+3 −9
Original line number Diff line number Diff line
@@ -35,12 +35,6 @@

namespace android {

sqlite3_stmt * compile(JNIEnv* env, jobject object,
                       sqlite3 * handle, jstring sqlString);

// From android_database_CursorWindow.cpp
CursorWindow * get_window_from_object(JNIEnv * env, jobject javaWindow);

static jfieldID gHandleField;
static jfieldID gStatementField;

@@ -105,7 +99,7 @@ static int finish_program_and_get_row_count(sqlite3_stmt *statement) {
    return numRows;
}

static jint native_fill_window(JNIEnv* env, jobject object, jobject javaWindow,
static jint native_fill_window(JNIEnv* env, jobject object, jint windowPtr,
                               jint startPos, jint offsetParam, jint maxRead, jint lastPos)
{
    int err;
@@ -142,7 +136,7 @@ static jint native_fill_window(JNIEnv* env, jobject object, jobject javaWindow,
    }

    // Get the native window
    window = get_window_from_object(env, javaWindow);
    window = reinterpret_cast<CursorWindow*>(windowPtr);
    if (!window) {
        LOGE("Invalid CursorWindow");
        jniThrowException(env, "java/lang/IllegalArgumentException",
@@ -360,7 +354,7 @@ static jstring native_column_name(JNIEnv* env, jobject object, jint columnIndex)
static JNINativeMethod sMethods[] =
{
     /* name, signature, funcPtr */
    {"native_fill_window", "(Landroid/database/CursorWindow;IIII)I",
    {"native_fill_window", "(IIIII)I",
            (void *)native_fill_window},
    {"native_column_count", "()I", (void*)native_column_count},
    {"native_column_name", "(I)Ljava/lang/String;", (void *)native_column_name},
Loading