Skip to content

Commit

Permalink
improve perf
Browse files Browse the repository at this point in the history
  • Loading branch information
xqdoo00o authored Jul 30, 2023
1 parent 439e801 commit aef6a4a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2958,16 +2958,17 @@
</script>
<script>
const stringToUint = string => {
let charList = string.split(''), uintArray = [];
for (let i = 0; i < charList.length; i++) {
uintArray.push(charList[i].charCodeAt(0));
let uintArray = new Uint8Array(string.length);
for (let i = 0; i < string.length; i++) {
uintArray[i] = string[i].charCodeAt(0);
}
return new Uint8Array(uintArray);
return uintArray;
}
const uintToString = uintArray => {
let str = "";
for (let i = 0; i < uintArray.byteLength; i++) {
str += String.fromCharCode(uintArray[i]);
let len = Math.ceil(uintArray.byteLength / 32767);
for (let i = 0; i < len; i++) {
str += String.fromCharCode.apply(null, uintArray.subarray(i * 32767, Math.min((i + 1) * 32767, uintArray.byteLength)));
}
return str;
}
Expand Down

0 comments on commit aef6a4a

Please sign in to comment.