Skip to content

Commit adb3313

Browse files
Adjust empty byte array initialization, retriving bytes from string
1 parent c2ef89e commit adb3313

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

sqlcipher/src/main/java/net/zetetic/database/sqlcipher/SQLiteDatabase.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ public static SQLiteDatabase openDatabase(String path, byte[] password, CursorFa
740740
*/
741741
public static SQLiteDatabase openDatabase(String path, CursorFactory factory, int flags,
742742
DatabaseErrorHandler errorHandler) {
743-
return openDatabase(path, new byte[0], factory, flags, errorHandler, null);
743+
return openDatabase(path, new byte[]{}, factory, flags, errorHandler, null);
744744
}
745745

746746
/**
@@ -2398,11 +2398,7 @@ public void enableLocalizedCollators() {
23982398
}
23992399

24002400
private static byte[] getBytes(String data) {
2401-
if(data == null || data.length() == 0) return new byte[0];
2402-
CharBuffer charBuffer = CharBuffer.wrap(data);
2403-
ByteBuffer byteBuffer = Charset.forName("UTF-8").encode(charBuffer);
2404-
byte[] result = new byte[byteBuffer.limit()];
2405-
byteBuffer.get(result);
2406-
return result;
2401+
if(data == null || data.length() == 0) return new byte[]{};
2402+
return data.getBytes(Charset.forName("UTF-8"));
24072403
}
24082404
}

0 commit comments

Comments
 (0)