-
Notifications
You must be signed in to change notification settings - Fork 0
/
sosie009-rhino-ensureIndex.tex
76 lines (75 loc) · 2.21 KB
/
sosie009-rhino-ensureIndex.tex
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
69
70
71
72
73
74
75
76
Listing \ref{lst:ensureIndex} is a valid sosie, not beautiful: the first assignment of \texttt{index} is useless
%Position: org.mozilla.javascript.UintMap:290
\begin{minipage}{\columnwidth}
\begin{lstlisting}[caption={\texttt{ensureIndex} in Rhino and a sosie},label=lst:ensureIndex,language=java,numbers=left]
//original
private int ensureIndex(int key, boolean intType) {
int index = -1;
//end transformation
int firstDeleted = -1;
int[] keys = this.keys;
if (keys != null) {
int fraction = key * A;
index = fraction >>> (32 - power);
%* {\color{gray} \emph{...} } *)
}
// Inserting of new key
if (check && keys != null && keys[index] != EMPTY)
Kit.codeBug();
if (firstDeleted >= 0) {
index = firstDeleted;
}
else {
// Need to consume empty entry: check occupation level
if (keys == null || occupiedCount * 4 >= (1 << power) * 3) {
// Too litle unused entries: rehash
rehashTable(intType);
return insertNewKey(key);
}
++occupiedCount;
}
keys[index] = key;
++keyCount;
return index;
}
//sosie
private int ensureIndex(int key, boolean intType) {
int index = 65536;
//end transformation
int firstDeleted = -1;
int[] keys = this.keys;
if (keys != null) {
int fraction = key * A;
index = fraction >>> (32 - power);
%* {\color{gray} \emph{...} } *)
}
// Inserting of new key
if (check && keys != null && keys[index] != EMPTY)
Kit.codeBug();
if (firstDeleted >= 0) {
index = firstDeleted;
}
else {
// Need to consume empty entry: check occupation level
if (keys == null || occupiedCount * 4 >= (1 << power) * 3) {
// Too litle unused entries: rehash
rehashTable(intType);
return insertNewKey(key);
}
++occupiedCount;
}
keys[index] = key;
++keyCount;
return index;
}
\end{lstlisting}
\tabcolsep=0.11cm
\begin{tabular}{>{\small}c>{\small}c>{\small}c>{\small}c>{\small}c>{\small}c>{\small}c>{\small}c}
\hline
\rowcolor{lightgray} \#tc & \#assert & transfo & node & min & max & median & mean \\
\rowcolor{lightgray} & & type & type & depth & depth & depth & depth \\
\hline
& & rep & & & & & \\
\hline
\end{tabular}
\end{minipage}