Skip to content

Commit d26e880

Browse files
committed
Use null character \u0000, instead of a space, when back-filling CharArray
1 parent 9a88a30 commit d26e880

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

library/core/src/commonMain/kotlin/io/matthewnelson/encoding/core/Encoder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public sealed class Encoder<C: EncoderDecoder.Config>(config: C): Decoder<C>(con
250250
if (i == maxSize) return@block a
251251
val copy = a.copyOf(i)
252252
if (encoder.config.backFillBuffers) {
253-
a.fill(' ', 0, i)
253+
a.fill('\u0000', 0, i)
254254
}
255255
copy
256256
}

library/core/src/commonMain/kotlin/io/matthewnelson/encoding/core/EncoderDecoder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ public abstract class EncoderDecoder<C: EncoderDecoder.Config>(config: C): Encod
122122
* data (e.g. a [StringBuilder], [CharArray], or [ByteArray]). Depending on the underlying
123123
* encoding/decoding operation, such as an array over-allocation due to [encodeOutMaxSize]
124124
* or [decodeOutMaxSize], those initially allocated buffers may not be returned as the
125-
* function's result. Prior versions of this library always back-filled them with `0` or a
126-
* space character, but that can be computationally expensive for large datasets and
125+
* function's result. Prior versions of this library always back-filled them with `0` or the
126+
* null character `\u0000`, but that can be computationally expensive for large datasets and
127127
* potentially unnecessary if data is known to not be sensitive in nature.
128128
*
129129
* If `true`, any non-result buffer allocations are back-filled before being de-referenced

0 commit comments

Comments
 (0)