annotate src/org/tmatesoft/hg/internal/ByteVector.java @ 711:a62079bc422b

Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 11 Oct 2013 21:35:41 +0200
parents 88afffd39899
children
rev   line source
574
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2013 TMate Software Ltd
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.internal;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19 import java.io.ByteArrayOutputStream;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
21 /**
711
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
22 * Alternative to {@link ByteArrayOutputStream}, with extra operation that prevent superfluous byte[] instances
574
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 *
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 * @author Artem Tikhomirov
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 * @author TMate Software Ltd.
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 */
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 public class ByteVector {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 private byte[] data;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 private int count;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 private final int increment;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 public ByteVector(int initialSize, int increment) {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 data = new byte[initialSize];
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 this.increment = increment;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 public void add(int b) {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 if (count == data.length) {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40 byte[] newData = new byte[count + increment];
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 System.arraycopy(data, 0, newData, 0, count);
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 data = newData;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44 data[count++] = (byte) b;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46
711
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
47 public int indexOf(int b) {
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
48 for (int i = 0; i < count; i++) {
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
49 if (data[i] == b) {
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
50 return i;
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
51 }
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
52 }
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
53 return -1;
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
54 }
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
55
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
56 public byte get(int i) {
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
57 if (i < 0 || i >= count) {
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
58 throw new IllegalArgumentException(String.valueOf(i));
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
59 }
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
60 return data[i];
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
61 }
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
62
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
63 public boolean isEmpty() {
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
64 return count == 0;
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
65 }
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
66
574
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
67 public int size() {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
68 return count;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
69 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
70
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
71 public void clear() {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
72 count = 0;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
73 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
74
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
75 public boolean equalsTo(byte[] array) {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
76 if (array == null || array.length != count) {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
77 return false;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
78 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79 for (int i = 0; i < count; i++) {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80 if (data[i] != array[i]) {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
81 return false;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
82 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84 return true;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
85 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
86
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
87 /**
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88 * Copies content of this vector into destination array.
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
89 * @param destination array, greater or equal to {@link #size()} of the vector
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
90 */
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
91 public void copyTo(byte[] destination) {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
92 if (destination == null || destination.length < count) {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
93 throw new IllegalArgumentException();
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
94 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
95 System.arraycopy(data, 0, destination, 0, count);
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
96 }
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
97
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
98 public byte[] toByteArray() {
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
99 byte[] rv = new byte[count];
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
100 copyTo(rv);
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
101 return rv;
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
102 }
711
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
103
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
104 public byte[] toByteArray(int from, int to) {
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
105 if (from > to) {
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
106 throw new IllegalArgumentException();
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
107 }
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
108 if (to > count) {
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
109 throw new IllegalArgumentException();
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
110 }
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
111 byte[] rv = new byte[to-from];
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
112 System.arraycopy(data, from, rv, 0, rv.length);
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
113 return rv;
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 574
diff changeset
114 }
574
88afffd39899 Improve memory consumption of HgManifest#getFileRevision(): avoid extra byte[] instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
115 }