-
Notifications
You must be signed in to change notification settings - Fork 341
Expand file tree
/
Copy pathNameN.java
More file actions
68 lines (61 loc) · 1.79 KB
/
NameN.java
File metadata and controls
68 lines (61 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package org.codehaus.jackson.sym;
/**
* Generic implementation of PName used for "long" names, where long
* means that its byte (UTF-8) representation is 13 bytes or more.
*/
public final class NameN
extends Name
{
final int[] mQuads;
final int mQuadLen;
NameN(String name, int hash, int[] quads, int quadLen)
{
super(name, hash);
/* We have specialized implementations for shorter
* names, so let's not allow runt instances here
*/
if (quadLen < 3) {
throw new IllegalArgumentException("Qlen must >= 3");
}
mQuads = quads;
mQuadLen = quadLen;
}
// Implies quad length == 1, never matches
@Override
public boolean equals(int quad) { return false; }
// Implies quad length == 2, never matches
@Override
public boolean equals(int quad1, int quad2) { return false; }
@Override
public boolean equals(int[] quads, int qlen)
{
if (qlen != mQuadLen) {
return false;
}
/* 26-Nov-2008, tatus: Strange, but it does look like
* unrolling here is counter-productive, reducing
* speed. Perhaps it prevents inlining by HotSpot or
* something...
*/
// Will always have >= 3 quads, can unroll
/*
if (quads[0] == mQuads[0]
&& quads[1] == mQuads[1]
&& quads[2] == mQuads[2]) {
for (int i = 3; i < qlen; ++i) {
if (quads[i] != mQuads[i]) {
return false;
}
}
return true;
}
*/
// or simpler way without unrolling:
for (int i = 0; i < qlen; ++i) {
if (quads[i] != mQuads[i]) {
return false;
}
}
return true;
}
}