serenity/Userland/Libraries
Andreas Kling 4ce5aeb312 LibWeb: Skip CSS tokenizer filtering when string has no '\r' or '\f'
When loading a canned version of reddit.com, we end up parsing many many
shadow tree style sheets of roughly ~170 KiB text each.

None of them have '\r' or '\f', yet we spend 2-3 ms for each sheet just
looping over and reconstructing the text to see if we need to normalize
any newlines.

This patch makes the common case faster in two ways:

- We use TextCodec::Decoder::to_utf8() instead of process()
  This way, we do a one-shot fast validation and conversion to UTF-8,
  instead of using the generic code-point-at-a-time callback API.

- We scan for '\r' and '\f' before filtering, and if neither is present,
  we simply use the unfiltered string.

With these changes, we now spend 0 ms in the filtering function for the
vast majority of style sheets I've seen so far.

(cherry picked from commit dba6216caa71796f25831908035cd9eb0fb54715)
2024-07-21 12:37:05 -04:00
..
LibAccelGfx
LibArchive
LibAudio LibAudio: Use clamp() in Sample::clip() 2024-07-06 22:24:20 +02:00
LibC Kernel+Userland: Prepare for considering VFSRootContext when mounting 2024-07-21 11:44:23 +02:00
LibCards
LibChess LibChess: Fix crash when importing PGN 2024-05-11 07:41:57 +01:00
LibCMake
LibCodeComprehension
LibCompress LibCompress: Detemplatize generate_huffman_lengths() 2024-07-01 00:29:39 +02:00
LibConfig
LibCore LibCore: Add System methods to handle the unshare syscall family 2024-07-21 11:44:23 +02:00
LibCoredump LibCoredump: Use AK::unwind_stack_from_frame_pointer 2024-05-14 14:02:06 -06:00
LibCpp
LibCrypt
LibCrypto LibCrypto: Remove FIXMEs regarding possible optimizations in SHA{1,256} 2024-07-12 18:30:07 -04:00
LibDebug HackStudio: Use AK::unwind_stack_from_frame_pointer 2024-05-14 14:02:06 -06:00
LibDesktop
LibDeviceTree
LibDiff
LibDNS
LibDSP
LibEDID
LibELF Kernel+Userland: Simplify loading of an ELF interpreter path 2024-07-21 15:38:52 +02:00
LibFileSystem
LibFileSystemAccessClient
LibGemini LibHTTP+LibCore+RequestServer: Use async streams for HTTP 2024-06-19 15:45:02 +02:00
LibGfx LibGfx/WebPWriter: Add support for writing color cache symbols 2024-07-15 08:47:34 -04:00
LibGL
LibGLSL
LibGPU
LibGUI LibGUI: Improve how SpinBox handles negative numbers 2024-07-19 21:20:52 +01:00
LibHTTP AK+LibTest: Choose definition of CO_TRY and CO_TRY_OR_FAIL more robustly 2024-06-29 20:15:05 -06:00
LibIDL LibIDL+LibWeb: Mark [FIXME] interfaces as [[Unimplemented]] 2024-06-26 16:34:37 +02:00
LibImageDecoderClient
LibIMAP
LibIPC LibIPC: Allow sync messages to completely block the event loop 2024-06-25 18:30:03 -06:00
LibJIT
LibJS LibJS: Implement CreatePerIterationEnvironment for 'for' statements 2024-07-21 11:31:13 -04:00
LibKeyboard
LibLine Documentation: Fix some minor ESL grammar issues 2024-07-03 00:17:46 +02:00
LibLocale
LibMain
LibManual
LibMarkdown
LibMedia LibMedia: Support videos with BT470BG color matrix 2024-07-13 17:37:23 -04:00
LibPartition Kernel: Prevent reference to unaligned u32 in MBRPartitionTable init 2024-05-27 17:35:42 +02:00
LibPCIDB
LibPDF LibPDF: Use draw_rect() to show debug clipping rects 2024-07-12 09:47:51 -04:00
LibProtocol LibWebSocket: Use HTTP::HeaderMap in WebSocket code 2024-06-26 18:50:27 +02:00
LibRegex Everywhere: Remove usages of template keyword with no parameter list 2024-06-25 17:42:49 +02:00
LibRIFF
LibSanitizer
LibSemVer
LibSoftGPU
LibSQL
LibSymbolication
LibSyntax LibSyntax: Remove minor unnecessary use of LibGUI 2024-06-02 20:00:29 +02:00
LibSystem
LibTest AK+LibTest: Choose definition of CO_TRY and CO_TRY_OR_FAIL more robustly 2024-06-29 20:15:05 -06:00
LibTextCodec LibTextCodec: Use generated lookup tables for all single byte decoders 2024-06-27 00:27:56 +02:00
LibThreading RequestServer+LibCore+LibTLS: Use coroutines for socket connection 2024-06-19 15:45:02 +02:00
LibTimeZone
LibTLS RequestServer+LibCore+LibTLS: Use coroutines for socket connection 2024-06-19 15:45:02 +02:00
LibUnicode AK+LibUnicode: Implement a case-insensitive variant of find_byte_offset 2024-06-01 07:37:54 +02:00
LibURL LibURL: Convert ASCII only URLs to lowercase during parsing 2024-06-27 14:00:51 +02:00
LibUSBDB
LibVirtGPU
LibVT
LibWasm LibWasm: Make Absolute/Negate<SignedIntegral> explicitly work mod 2^N 2024-07-16 17:35:43 +02:00
LibWeb LibWeb: Skip CSS tokenizer filtering when string has no '\r' or '\f' 2024-07-21 12:37:05 -04:00
LibWebSocket LibWebSocket: Use HTTP::HeaderMap in WebSocket code 2024-06-26 18:50:27 +02:00
LibWebView LibWebView: Trim whitespace when sanitizing file paths 2024-07-14 19:34:49 -04:00
LibX86
LibXML
CMakeLists.txt LibMedia: Rename LibVideo to LibMedia 2024-07-04 22:09:32 +02:00