@@ -37,14 +37,6 @@ private Bits() { }
37
37
38
38
// -- Swapping --
39
39
40
- private static short swap (short x ) {
41
- return Short .reverseBytes (x );
42
- }
43
-
44
- private static char swap (char x ) {
45
- return Character .reverseBytes (x );
46
- }
47
-
48
40
private static int swap (int x ) {
49
41
return Integer .reverseBytes (x );
50
42
}
@@ -69,12 +61,6 @@ private static boolean isAddressAligned(long a, int datumSize) {
69
61
70
62
// -- Primitives stored per byte
71
63
72
- private static byte char1 (char x ) { return (byte )(x >> 8 ); }
73
- private static byte char0 (char x ) { return (byte )(x ); }
74
-
75
- private static byte short1 (short x ) { return (byte )(x >> 8 ); }
76
- private static byte short0 (short x ) { return (byte )(x ); }
77
-
78
64
private static byte int3 (int x ) { return (byte )(x >> 24 ); }
79
65
private static byte int2 (int x ) { return (byte )(x >> 16 ); }
80
66
private static byte int1 (int x ) { return (byte )(x >> 8 ); }
@@ -89,16 +75,6 @@ private static boolean isAddressAligned(long a, int datumSize) {
89
75
private static byte long1 (long x ) { return (byte )(x >> 8 ); }
90
76
private static byte long0 (long x ) { return (byte )(x ); }
91
77
92
- private static void putCharBigEndianUnaligned (long a , char x ) {
93
- putByte_ (a , char1 (x ));
94
- putByte_ (a + 1 , char0 (x ));
95
- }
96
-
97
- private static void putShortBigEndianUnaligned (long a , short x ) {
98
- putByte_ (a , short1 (x ));
99
- putByte_ (a + 1 , short0 (x ));
100
- }
101
-
102
78
private static void putIntBigEndianUnaligned (long a , int x ) {
103
79
putByte_ (a , int3 (x ));
104
80
putByte_ (a + 1 , int2 (x ));
@@ -129,26 +105,10 @@ private static void putByte_(long a, byte b) {
129
105
unsafe .putByte (a , b );
130
106
}
131
107
132
- private static void putBoolean_ (long a , boolean x ) {
133
- unsafe .putBoolean (null , a , x );
134
- }
135
-
136
- private static void putChar_ (long a , char x ) {
137
- unsafe .putChar (a , bigEndian ? x : swap (x ));
138
- }
139
-
140
- private static void putShort_ (long a , short x ) {
141
- unsafe .putShort (a , bigEndian ? x : swap (x ));
142
- }
143
-
144
108
private static void putInt_ (long a , int x ) {
145
109
unsafe .putInt (a , bigEndian ? x : swap (x ));
146
110
}
147
111
148
- private static void putLong_ (long a , long x ) {
149
- unsafe .putLong (a , bigEndian ? x : swap (x ));
150
- }
151
-
152
112
private static void putFloat_ (long a , float x ) {
153
113
unsafe .putFloat (a , bigEndian ? x : swap (x ));
154
114
}
@@ -158,34 +118,6 @@ private static void putDouble_(long a, double x) {
158
118
}
159
119
160
120
// external api
161
- public static int putByte (long a , byte x ) {
162
- putByte_ (a , x );
163
- return Byte .BYTES ;
164
- }
165
-
166
- public static int putBoolean (long a , boolean x ) {
167
- putBoolean_ (a , x );
168
- return Byte .BYTES ;
169
- }
170
-
171
- static int putChar (long a , char x ) {
172
- if (unalignedAccess || isAddressAligned (a , Character .BYTES )) {
173
- putChar_ (a , x );
174
- return Character .BYTES ;
175
- }
176
- putCharBigEndianUnaligned (a , x );
177
- return Character .BYTES ;
178
- }
179
-
180
- static int putShort (long a , short x ) {
181
- if (unalignedAccess || isAddressAligned (a , Short .BYTES )) {
182
- putShort_ (a , x );
183
- return Short .BYTES ;
184
- }
185
- putShortBigEndianUnaligned (a , x );
186
- return Short .BYTES ;
187
- }
188
-
189
121
public static int putInt (long a , int x ) {
190
122
if (unalignedAccess || isAddressAligned (a , Integer .BYTES )) {
191
123
putInt_ (a , x );
@@ -195,15 +127,6 @@ public static int putInt(long a, int x) {
195
127
return Integer .BYTES ;
196
128
}
197
129
198
- static int putLong (long a , long x ) {
199
- if (unalignedAccess || isAddressAligned (a , Long .BYTES )) {
200
- putLong_ (a , x );
201
- return Long .BYTES ;
202
- }
203
- putLongBigEndianUnaligned (a , x );
204
- return Long .BYTES ;
205
- }
206
-
207
130
public static int putFloat (long a , float x ) {
208
131
if (unalignedAccess || isAddressAligned (a , Float .BYTES )) {
209
132
putFloat_ (a , x );
0 commit comments