mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-02-15 07:28:59 +00:00
Improve performance of link preview parsing
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
@@ -290,8 +290,6 @@ const getHtmlDocument = async (
|
||||
abortSignal: AbortSignal,
|
||||
logger: Pick<LoggerType, 'warn'> = log
|
||||
): Promise<HTMLDocument> => {
|
||||
let result: HTMLDocument = emptyHtmlDocument();
|
||||
|
||||
const buffer = new Uint8Array(MAX_HTML_BYTES_TO_LOAD);
|
||||
let bytesLoadedSoFar = 0;
|
||||
|
||||
@@ -313,8 +311,6 @@ const getHtmlDocument = async (
|
||||
buffer.set(truncatedChunk, bytesLoadedSoFar);
|
||||
bytesLoadedSoFar += truncatedChunk.byteLength;
|
||||
|
||||
result = parseHtmlBytes(buffer.slice(0, bytesLoadedSoFar), httpCharset);
|
||||
|
||||
const hasLoadedMaxBytes = bytesLoadedSoFar >= buffer.length;
|
||||
if (hasLoadedMaxBytes) {
|
||||
break;
|
||||
@@ -326,6 +322,7 @@ const getHtmlDocument = async (
|
||||
);
|
||||
}
|
||||
|
||||
const result = parseHtmlBytes(buffer.slice(0, bytesLoadedSoFar), httpCharset);
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user