Skip to content

Commit 0785370

Browse files
committed
Prevent boxing in Scala 2.x
1 parent 61f5f9a commit 0785370

File tree

8 files changed

+664
-248
lines changed

8 files changed

+664
-248
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# 1.4.0-RC1
1+
# 1.4.0
22

33
* `UnivEq` is now a `final class` instead of a trait
4+
* Optimise `==*` and `!=*` methods (to avoid boxing and drop the `UnivEq` evidence)
45
* Scala 3 support
56
* Upgrade deps
67

project/Build.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,16 @@ object UnivEqBuild {
9797
libraryDependencies += Dep.ScalaCollCompat.value)
9898
.jvmSettings(
9999
Test / fork := true,
100-
Test / javaOptions += ("-Dclasses.dir=" + (Test / classDirectory).value.absolutePath))
100+
Test / javaOptions += ("-Dclasses.dir=" + (Test / classDirectory).value.absolutePath),
101+
Test / unmanagedResourceDirectories ++= {
102+
val base = (Test / resourceDirectory).value.absolutePath
103+
CrossVersion.partialVersion(scalaVersion.value) match {
104+
case Some((2, n)) => Seq(file(base + "-2." + n))
105+
case Some((3, _)) => Seq(file(base + "-3"))
106+
case _ => Nil
107+
}
108+
}
109+
)
101110
.jsSettings(
102111
libraryDependencies += Dep.ScalaJsDom.value)
103112

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
Compiled from "BytecodeTest.scala"
2+
public class japgolly.univeq.BytecodeTest$TestSubject {
3+
public boolean testByte(byte);
4+
Code:
5+
0: iload_1
6+
1: iload_1
7+
2: if_icmpeq 9
8+
5: iconst_1
9+
6: goto 10
10+
9: iconst_0
11+
10: ifne 26
12+
13: iload_1
13+
14: iload_1
14+
15: if_icmpne 22
15+
18: iconst_1
16+
19: goto 23
17+
22: iconst_0
18+
23: ifeq 28
19+
26: iconst_1
20+
27: ireturn
21+
28: iconst_0
22+
29: ireturn
23+
24+
public boolean testChar(char);
25+
Code:
26+
0: iload_1
27+
1: iload_1
28+
2: if_icmpeq 9
29+
5: iconst_1
30+
6: goto 10
31+
9: iconst_0
32+
10: ifne 26
33+
13: iload_1
34+
14: iload_1
35+
15: if_icmpne 22
36+
18: iconst_1
37+
19: goto 23
38+
22: iconst_0
39+
23: ifeq 28
40+
26: iconst_1
41+
27: ireturn
42+
28: iconst_0
43+
29: ireturn
44+
45+
public boolean testShort(short);
46+
Code:
47+
0: iload_1
48+
1: iload_1
49+
2: if_icmpeq 9
50+
5: iconst_1
51+
6: goto 10
52+
9: iconst_0
53+
10: ifne 26
54+
13: iload_1
55+
14: iload_1
56+
15: if_icmpne 22
57+
18: iconst_1
58+
19: goto 23
59+
22: iconst_0
60+
23: ifeq 28
61+
26: iconst_1
62+
27: ireturn
63+
28: iconst_0
64+
29: ireturn
65+
66+
public boolean testInt(int);
67+
Code:
68+
0: iload_1
69+
1: iload_1
70+
2: if_icmpeq 9
71+
5: iconst_1
72+
6: goto 10
73+
9: iconst_0
74+
10: ifne 26
75+
13: iload_1
76+
14: iload_1
77+
15: if_icmpne 22
78+
18: iconst_1
79+
19: goto 23
80+
22: iconst_0
81+
23: ifeq 28
82+
26: iconst_1
83+
27: ireturn
84+
28: iconst_0
85+
29: ireturn
86+
87+
public boolean testLong(long);
88+
Code:
89+
0: lload_1
90+
1: lload_1
91+
2: lcmp
92+
3: ifeq 10
93+
6: iconst_1
94+
7: goto 11
95+
10: iconst_0
96+
11: ifne 28
97+
14: lload_1
98+
15: lload_1
99+
16: lcmp
100+
17: ifne 24
101+
20: iconst_1
102+
21: goto 25
103+
24: iconst_0
104+
25: ifeq 30
105+
28: iconst_1
106+
29: ireturn
107+
30: iconst_0
108+
31: ireturn
109+
110+
public boolean testFloat(float);
111+
Code:
112+
0: fload_1
113+
1: fload_1
114+
2: fcmpl
115+
3: ifeq 10
116+
6: iconst_1
117+
7: goto 11
118+
10: iconst_0
119+
11: ifne 28
120+
14: fload_1
121+
15: fload_1
122+
16: fcmpl
123+
17: ifne 24
124+
20: iconst_1
125+
21: goto 25
126+
24: iconst_0
127+
25: ifeq 30
128+
28: iconst_1
129+
29: ireturn
130+
30: iconst_0
131+
31: ireturn
132+
133+
public boolean testDouble(double);
134+
Code:
135+
0: dload_1
136+
1: dload_1
137+
2: dcmpl
138+
3: ifeq 10
139+
6: iconst_1
140+
7: goto 11
141+
10: iconst_0
142+
11: ifne 28
143+
14: dload_1
144+
15: dload_1
145+
16: dcmpl
146+
17: ifne 24
147+
20: iconst_1
148+
21: goto 25
149+
24: iconst_0
150+
25: ifeq 30
151+
28: iconst_1
152+
29: ireturn
153+
30: iconst_0
154+
31: ireturn
155+
156+
public boolean testBoolean(boolean);
157+
Code:
158+
0: iload_1
159+
1: iload_1
160+
2: if_icmpeq 9
161+
5: iconst_1
162+
6: goto 10
163+
9: iconst_0
164+
10: ifne 26
165+
13: iload_1
166+
14: iload_1
167+
15: if_icmpne 22
168+
18: iconst_1
169+
19: goto 23
170+
22: iconst_0
171+
23: ifeq 28
172+
26: iconst_1
173+
27: ireturn
174+
28: iconst_0
175+
29: ireturn
176+
177+
public japgolly.univeq.BytecodeTest$TestSubject();
178+
Code:
179+
0: aload_0
180+
1: invokespecial #39 // Method java/lang/Object."<init>":()V
181+
4: return
182+
}
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
Compiled from "BytecodeTest.scala"
2+
public class japgolly.univeq.BytecodeTest$TestSubject {
3+
public boolean testByte(byte);
4+
Code:
5+
0: iload_1
6+
1: iload_1
7+
2: if_icmpeq 9
8+
5: iconst_1
9+
6: goto 10
10+
9: iconst_0
11+
10: ifne 26
12+
13: iload_1
13+
14: iload_1
14+
15: if_icmpne 22
15+
18: iconst_1
16+
19: goto 23
17+
22: iconst_0
18+
23: ifeq 28
19+
26: iconst_1
20+
27: ireturn
21+
28: iconst_0
22+
29: ireturn
23+
24+
public boolean testChar(char);
25+
Code:
26+
0: iload_1
27+
1: iload_1
28+
2: if_icmpeq 9
29+
5: iconst_1
30+
6: goto 10
31+
9: iconst_0
32+
10: ifne 26
33+
13: iload_1
34+
14: iload_1
35+
15: if_icmpne 22
36+
18: iconst_1
37+
19: goto 23
38+
22: iconst_0
39+
23: ifeq 28
40+
26: iconst_1
41+
27: ireturn
42+
28: iconst_0
43+
29: ireturn
44+
45+
public boolean testShort(short);
46+
Code:
47+
0: iload_1
48+
1: iload_1
49+
2: if_icmpeq 9
50+
5: iconst_1
51+
6: goto 10
52+
9: iconst_0
53+
10: ifne 26
54+
13: iload_1
55+
14: iload_1
56+
15: if_icmpne 22
57+
18: iconst_1
58+
19: goto 23
59+
22: iconst_0
60+
23: ifeq 28
61+
26: iconst_1
62+
27: ireturn
63+
28: iconst_0
64+
29: ireturn
65+
66+
public boolean testInt(int);
67+
Code:
68+
0: iload_1
69+
1: iload_1
70+
2: if_icmpeq 9
71+
5: iconst_1
72+
6: goto 10
73+
9: iconst_0
74+
10: ifne 26
75+
13: iload_1
76+
14: iload_1
77+
15: if_icmpne 22
78+
18: iconst_1
79+
19: goto 23
80+
22: iconst_0
81+
23: ifeq 28
82+
26: iconst_1
83+
27: ireturn
84+
28: iconst_0
85+
29: ireturn
86+
87+
public boolean testLong(long);
88+
Code:
89+
0: lload_1
90+
1: lload_1
91+
2: lcmp
92+
3: ifeq 10
93+
6: iconst_1
94+
7: goto 11
95+
10: iconst_0
96+
11: ifne 28
97+
14: lload_1
98+
15: lload_1
99+
16: lcmp
100+
17: ifne 24
101+
20: iconst_1
102+
21: goto 25
103+
24: iconst_0
104+
25: ifeq 30
105+
28: iconst_1
106+
29: ireturn
107+
30: iconst_0
108+
31: ireturn
109+
110+
public boolean testFloat(float);
111+
Code:
112+
0: fload_1
113+
1: fload_1
114+
2: fcmpl
115+
3: ifeq 10
116+
6: iconst_1
117+
7: goto 11
118+
10: iconst_0
119+
11: ifne 28
120+
14: fload_1
121+
15: fload_1
122+
16: fcmpl
123+
17: ifne 24
124+
20: iconst_1
125+
21: goto 25
126+
24: iconst_0
127+
25: ifeq 30
128+
28: iconst_1
129+
29: ireturn
130+
30: iconst_0
131+
31: ireturn
132+
133+
public boolean testDouble(double);
134+
Code:
135+
0: dload_1
136+
1: dload_1
137+
2: dcmpl
138+
3: ifeq 10
139+
6: iconst_1
140+
7: goto 11
141+
10: iconst_0
142+
11: ifne 28
143+
14: dload_1
144+
15: dload_1
145+
16: dcmpl
146+
17: ifne 24
147+
20: iconst_1
148+
21: goto 25
149+
24: iconst_0
150+
25: ifeq 30
151+
28: iconst_1
152+
29: ireturn
153+
30: iconst_0
154+
31: ireturn
155+
156+
public boolean testBoolean(boolean);
157+
Code:
158+
0: iload_1
159+
1: iload_1
160+
2: if_icmpeq 9
161+
5: iconst_1
162+
6: goto 10
163+
9: iconst_0
164+
10: ifne 26
165+
13: iload_1
166+
14: iload_1
167+
15: if_icmpne 22
168+
18: iconst_1
169+
19: goto 23
170+
22: iconst_0
171+
23: ifeq 28
172+
26: iconst_1
173+
27: ireturn
174+
28: iconst_0
175+
29: ireturn
176+
177+
public japgolly.univeq.BytecodeTest$TestSubject();
178+
Code:
179+
0: aload_0
180+
1: invokespecial #39 // Method java/lang/Object."<init>":()V
181+
4: return
182+
}

0 commit comments

Comments
 (0)