tuned: avoid redundant copy of potentially large array;
authorwenzelm
Sat, 22 Oct 2022 16:56:17 +0200
changeset 76361 3b9f36ef7365
parent 76358 cff0828c374f
child 76362 1928405a409b
tuned: avoid redundant copy of potentially large array;
src/Pure/General/bytes.scala
--- a/src/Pure/General/bytes.scala	Fri Oct 21 21:39:38 2022 +0200
+++ b/src/Pure/General/bytes.scala	Sat Oct 22 16:56:17 2022 +0200
@@ -238,7 +238,7 @@
         new Bytes(result.toByteArray, 0, result.size)
       case options_zstd: Compress.Options_Zstd =>
         Zstd.init()
-        Bytes(zstd.Zstd.compress(array, options_zstd.level))
+        Bytes(zstd.Zstd.compress(if (offset == 0) bytes else array, options_zstd.level))
     }
   }