From 6f9097489611f2e1d581c9ebe07ce83d2364344c Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 6 Oct 2024 06:23:25 +0300 Subject: [PATCH] BAN: Fix StringView::starts_with I have no idea what i had been thinking when writing this code :D --- BAN/include/BAN/StringView.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/BAN/include/BAN/StringView.h b/BAN/include/BAN/StringView.h index 40f8d8500c..2fe5c90749 100644 --- a/BAN/include/BAN/StringView.h +++ b/BAN/include/BAN/StringView.h @@ -186,15 +186,10 @@ namespace BAN { if (target.size() > m_size) return false; - for (size_type i = 0; i < m_size - target.size(); i++) - { - bool valid = true; - for (size_type j = 0; j < target.size() && valid; j++) - valid = (m_data[i + j] == target[j]); - if (valid) - return true; - } - return false; + for (size_type i = 0; i < target.size(); i++) + if (m_data[i] != target[i]) + return false; + return true; } constexpr bool contains(char ch) const