Commit 79e9d18 1 parent 25a2729 commit 79e9d18 Copy full SHA for 79e9d18
File tree 1 file changed +10
-11
lines changed
1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -35,28 +35,27 @@ for (let i = 0; i < 64; i++) {
35
35
36
36
export function encodeFast ( input : Uint8Array ) : Uint8Array {
37
37
const output32 = new Uint32Array ( Math . ceil ( input . length / 3 ) ) ;
38
- const output8 = new Uint8Array ( output32 . buffer ) ;
39
38
let i , j ;
40
39
for ( i = 2 , j = 0 ; i < input . length ; i += 3 , j ++ ) {
41
40
output32 [ j ] =
42
41
base64codes1 [ input [ i - 2 ] | ( ( input [ i - 1 ] & 0xf0 ) << 4 ) ] |
43
42
base64codes2 [ input [ i ] | ( ( input [ i - 1 ] & 0x0f ) << 8 ) ] ;
44
43
}
45
- const index = j * 4 ;
46
44
if ( i === input . length + 1 ) {
47
45
// 1 octet yet to write
48
- output8 [ index ] = base64codes [ input [ i - 2 ] >> 2 ] ;
49
- output8 [ index + 1 ] = base64codes [ ( input [ i - 2 ] & 0x03 ) << 4 ] ;
50
- output8 [ index + 2 ] = 61 ;
51
- output8 [ index + 3 ] = 61 ;
46
+ output32 [ j ] =
47
+ base64codes [ input [ i - 2 ] >> 2 ] |
48
+ ( base64codes [ ( input [ i - 2 ] & 0x03 ) << 4 ] << 8 ) |
49
+ ( 15677 << 16 ) ;
52
50
}
53
51
if ( i === input . length ) {
54
52
// 2 octets yet to write
55
- output8 [ index ] = base64codes [ input [ i - 2 ] >> 2 ] ;
56
- output8 [ index + 1 ] =
57
- base64codes [ ( ( input [ i - 2 ] & 0x03 ) << 4 ) | ( input [ i - 1 ] >> 4 ) ] ;
58
- output8 [ index + 2 ] = base64codes [ ( input [ i - 1 ] & 0x0f ) << 2 ] ;
59
- output8 [ index + 3 ] = 61 ;
53
+ output32 [ j ] =
54
+ base64codes [ input [ i - 2 ] >> 2 ] |
55
+ ( base64codes [ ( ( input [ i - 2 ] & 0x03 ) << 4 ) | ( input [ i - 1 ] >> 4 ) ] << 8 ) |
56
+ ( base64codes [ ( input [ i - 1 ] & 0x0f ) << 2 ] << 16 ) |
57
+ ( 61 << 24 ) ;
60
58
}
59
+ const output8 = new Uint8Array ( output32 . buffer ) ;
61
60
return output8 ;
62
61
}
You can’t perform that action at this time.
0 commit comments