дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
Pasting an image into a terminal or a Markdown file, or saving bytes from the UI, sent the data as a JSON array of numbers (3.6x the size), which Tauri and the remote server parse into a serde_json::Value first (~50x the bytes in memory: a 20 MB image took ~2.2 GB peak heap and 640 ms). Binary command arguments (fs_create_file_bytes, term_store_image) now travel as base64 text (IpcBytes): the same 20 MB takes ~112 MB and 32 ms. Native image drops reuse the base64 they already have. Co-authored-by: Mr0Bread <[email protected]>
12 рядки
539 B
TypeScript
12 рядки
539 B
TypeScript
/**
|
|
* Binary command arguments (`IpcBytes` in Rust) cross IPC as base64 text: as a JSON number array
|
|
* they take 3.6x the size and a parsed `Value` tree of roughly 50x.
|
|
*/
|
|
export function toBase64(bytes: Uint8Array): string {
|
|
const parts: string[] = [];
|
|
// `apply` with a typed array is about 5x faster than spreading it (20 MB: 70 ms vs 380 ms).
|
|
for (let i = 0; i < bytes.length; i += 0x8000)
|
|
parts.push(String.fromCharCode.apply(null, bytes.subarray(i, i + 0x8000) as unknown as number[]));
|
|
return btoa(parts.join(""));
|
|
}
|