Wrap and copy can no longer return null

This commit is contained in:
Robinson 2023-07-02 02:44:19 +02:00
parent 647e25da39
commit 1629dd276c
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
1 changed files with 4 additions and 12 deletions

View File

@ -33,24 +33,16 @@ class ByteArrayWrapper(
* Makes a safe copy of the byte array, so that changes to the original do not affect the wrapper. * Makes a safe copy of the byte array, so that changes to the original do not affect the wrapper.
* One side effect is that additional memory is used. * One side effect is that additional memory is used.
*/ */
fun copy(data: ByteArray?): ByteArrayWrapper? { fun copy(data: ByteArray): ByteArrayWrapper {
return if (data == null) { return ByteArrayWrapper(data, true)
null
} else {
ByteArrayWrapper(data, true)
}
} }
/** /**
* Does not make a copy of the data, so changes to the original will also affect the wrapper. * Does not make a copy of the data, so changes to the original will also affect the wrapper.
* One side effect is that no extra memory is needed. * One side effect is that no extra memory is needed.
*/ */
fun wrap(data: ByteArray?): ByteArrayWrapper? { fun wrap(data: ByteArray): ByteArrayWrapper {
return if (data == null) { return ByteArrayWrapper(data, false)
null
} else {
ByteArrayWrapper(data, false)
}
} }
} }