Remove changes to ByteArray and minor cleanup

This commit is contained in:
Jim 2020-06-10 09:34:40 -04:00
parent 1c7b66a7b7
commit 9e14516ddf
2 changed files with 0 additions and 31 deletions

View File

@ -21,7 +21,6 @@ cdef void release_args(JNIEnv *j_env, tuple definition_args, bint pass_by_refere
jstringy_arg(argtype):
j_env[0].DeleteLocalRef(j_env, j_args[index].l)
elif argtype[0] == '[':
# if getattr(py_arg, '_JNIUS_PASS_BY_REFERENCE', True):
if pass_by_reference:
ret = convert_jarray_to_python(j_env, argtype[1:], j_args[index].l)
try:
@ -587,12 +586,6 @@ cdef jobject convert_pyarray_to_java(JNIEnv *j_env, definition, pyarray) except
a_bytes = pyarray
j_env[0].SetByteArrayRegion(j_env,
ret, 0, array_size, <const_jbyte *>a_bytes._buf)
## this makes ByteArrays slow
# for i in range(array_size):
# c_tmp = pyarray[i]
# j_byte = <signed char>c_tmp
# j_env[0].SetByteArrayRegion(j_env,
# ret, i, 1, &j_byte)
elif isinstance(pyarray, (bytearray, bytes)):
j_bytes = <signed char *>pyarray
j_env[0].SetByteArrayRegion(j_env,

View File

@ -18,13 +18,11 @@ cdef class ByteArray:
cdef long _size
cdef unsigned char *_buf
cdef unsigned char[:] _arr
cdef public bint _JNIUS_PASS_BY_REFERENCE
def __cinit__(self):
self._size = 0
self._buf = NULL
self._arr = None
self._JNIUS_PASS_BY_REFERENCE = True
def __dealloc__(self):
cdef JNIEnv *j_env
@ -66,28 +64,6 @@ cdef class ByteArray:
xx = index
return self._arr[xx]
def __setitem__(self, index, val):
cdef long xx
cdef int x
cdef unsigned char *vals
cdef long start
cdef long stop
cdef long step
if isinstance(index, slice):
vals = val
if self._size:
(start, stop, step) = index.indices(self._size)
# the following is faster than `range(start, stop, step)`
for x in range(((step - 1) + stop - start) // step):
xx = x
self._arr[start + xx * step] = vals[xx]
else:
xx = index
self._arr[xx] = val
def pass_by_reference(self, pref):
self._JNIUS_PASS_BY_REFERENCE = pref
def __richcmp__(self, other, op):
cdef ByteArray b_other
if isinstance(other, (list, tuple)):