From 51afbf5280483ed9201aef74e7ebacea0bbcd3e1 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sat, 5 Jul 2025 11:48:43 -0400 Subject: [PATCH] AK: Simplify BOM parsing in String::from_utf8_with_replacement_character --- AK/String.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AK/String.cpp b/AK/String.cpp index 52cfe7e3716..1ae9923ecab 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -24,7 +24,7 @@ namespace AK { String String::from_utf8_with_replacement_character(StringView view, WithBOMHandling with_bom_handling) { - if (auto bytes = view.bytes(); with_bom_handling == WithBOMHandling::Yes && bytes.size() >= 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) + if (auto bytes = view.bytes(); with_bom_handling == WithBOMHandling::Yes && bytes.starts_with({ { 0xEF, 0xBB, 0xBF } })) view = view.substring_view(3); if (Utf8View(view).validate())