MCPcopy Index your code
hub / github.com/google/brotli / unpackDictionaryData

Method unpackDictionaryData

java/org/brotli/dec/DictionaryData.java:40–72  ·  view source on GitHub ↗
(ByteBuffer dictionary, String data0, String data1,
      String skipFlip, int[] sizeBits, String sizeBitsData)

Source from the content-addressed store, hash-verified

38 private static final int DICTIONARY_DATA_DEBUG = Utils.isDebugMode();
39
40 private static void unpackDictionaryData(ByteBuffer dictionary, String data0, String data1,
41 String skipFlip, int[] sizeBits, String sizeBitsData) {
42 // Initialize lower 7 bits of every byte in the dictionary.
43 final byte[] dict = Utils.toUsAsciiBytes(data0 + data1);
44 final int[] skipFlipRunes = Utils.toUtf8Runes(skipFlip);
45 if (DICTIONARY_DATA_DEBUG != 0) {
46 if (dict.length != dictionary.capacity()) {
47 throw new RuntimeException("Corrupted brotli dictionary");
48 }
49 }
50
51 // Toggle high bit using run-length delta encoded "skipFlip".
52 int offset = 0;
53 final int n = skipFlipRunes.length >> 1;
54 for (int i = 0; i < n; ++i) {
55 final int skip = skipFlipRunes[2 * i] - 36;
56 final int flip = skipFlipRunes[2 * i + 1] - 36;
57 for (int j = 0; j < skip; ++j) {
58 dict[offset] = (byte) ((int) dict[offset] ^ 3);
59 offset++;
60 }
61 for (int j = 0; j < flip; ++j) {
62 dict[offset] = (byte) ((int) dict[offset] ^ 236);
63 offset++;
64 }
65 }
66
67 for (int i = 0; i < sizeBitsData.length(); ++i) {
68 sizeBits[i] = (int) sizeBitsData.charAt(i) - 65;
69 }
70
71 dictionary.put(dict);
72 }
73
74 static {
75 final ByteBuffer dictionaryData = ByteBuffer.allocateDirect(122784);

Callers 1

DictionaryDataClass · 0.95

Calls 3

toUsAsciiBytesMethod · 0.95
toUtf8RunesMethod · 0.95
lengthMethod · 0.45

Tested by

no test coverage detected