mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-05-02 07:04:27 +02:00
remove duplicate code
This commit is contained in:
parent
22d4fb9b5d
commit
4dd7eaf1ed
@ -151,18 +151,11 @@ public abstract class BlockItem extends Block {
|
|||||||
protected static boolean getBit(byte[] bts, int byteOffset, int bitIndex){
|
protected static boolean getBit(byte[] bts, int byteOffset, int bitIndex){
|
||||||
return (((bts[byteOffset] & 0xff) >>bitIndex) & 0x1) == 1;
|
return (((bts[byteOffset] & 0xff) >>bitIndex) & 0x1) == 1;
|
||||||
}
|
}
|
||||||
protected static void putBit(byte[] bts, int byteOffset, int bitIndex, boolean bit){
|
protected static void putBit(byte[] bytes, int byteOffset, int bitIndex, boolean bit){
|
||||||
int val=bts[byteOffset] & 0xff;
|
int mask = 1 << bitIndex;
|
||||||
int left=val>>bitIndex;
|
int add = bit ? mask : 0;
|
||||||
if(bit){
|
mask = (~mask) & 0xff;
|
||||||
left=left|0x1;
|
int value = (bytes[byteOffset] & mask) | add;
|
||||||
}else {
|
bytes[byteOffset] = (byte) value;
|
||||||
left=left & 0xFE;
|
|
||||||
}
|
|
||||||
left=left<<bitIndex;
|
|
||||||
bitIndex=8-bitIndex;
|
|
||||||
int right=(0xFF>>bitIndex) & val;
|
|
||||||
val=left|right;
|
|
||||||
bts[byteOffset]=(byte) val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,14 +88,10 @@ public class ByteArray extends BlockItem {
|
|||||||
bts[index]=value;
|
bts[index]=value;
|
||||||
}
|
}
|
||||||
public boolean getBit(int byteOffset, int bitIndex){
|
public boolean getBit(int byteOffset, int bitIndex){
|
||||||
return ((get(byteOffset)>>bitIndex) & 0x1) == 1;
|
return getBit(getBytesInternal(), byteOffset, bitIndex);
|
||||||
}
|
}
|
||||||
public void putBit(int byteOffset, int bitIndex, boolean bit){
|
public void putBit(int byteOffset, int bitIndex, boolean bit){
|
||||||
int mask = 1 << bitIndex;
|
putBit(getBytesInternal(), byteOffset, bitIndex, bit);
|
||||||
int add = bit ? mask : 0;
|
|
||||||
mask = (~mask) & 0xff;
|
|
||||||
int value = (get(byteOffset) & mask) | add;
|
|
||||||
putByte(byteOffset, value);
|
|
||||||
}
|
}
|
||||||
public final void putShort(int offset, int value){
|
public final void putShort(int offset, int value){
|
||||||
putShort(offset, (short) value);
|
putShort(offset, (short) value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user