/* Copyright 2015 Google Inc. All Rights Reserved. Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ namespace Org.Brotli.Dec { /// A set of utility methods. internal sealed class Utils { private static readonly byte[] ByteZeroes = new byte[1024]; private static readonly int[] IntZeroes = new int[1024]; /// Fills byte array with zeroes. /// /// Fills byte array with zeroes. ///

Current implementation uses /// /// , so it should be used for length not /// less than 16. /// /// array to fill with zeroes /// the first byte to fill /// number of bytes to change internal static void FillWithZeroes(byte[] dest, int offset, int length) { int cursor = 0; while (cursor < length) { int step = System.Math.Min(cursor + 1024, length) - cursor; System.Array.Copy(ByteZeroes, 0, dest, offset + cursor, step); cursor += step; } } ///

Fills int array with zeroes. /// /// Fills int array with zeroes. ///

Current implementation uses /// /// , so it should be used for length not /// less than 16. /// /// array to fill with zeroes /// the first item to fill /// number of item to change internal static void FillWithZeroes(int[] dest, int offset, int length) { int cursor = 0; while (cursor < length) { int step = System.Math.Min(cursor + 1024, length) - cursor; System.Array.Copy(IntZeroes, 0, dest, offset + cursor, step); cursor += step; } } } }