From 473c934826bce0d0f1ffe207d570e91d70ac918b Mon Sep 17 00:00:00 2001 From: qicosmos Date: Mon, 10 Jul 2023 14:11:07 +0800 Subject: [PATCH] use memcpy --- benchmark/xml_benchmark.cpp | 1 + frozen/string.h | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/benchmark/xml_benchmark.cpp b/benchmark/xml_benchmark.cpp index 7e5260e5..e5dd563a 100644 --- a/benchmark/xml_benchmark.cpp +++ b/benchmark/xml_benchmark.cpp @@ -1,5 +1,6 @@ #include "../rapidxml/rapidxml.hpp" #include "xml_bench.hpp" +#include class ScopedTimer { public: diff --git a/frozen/string.h b/frozen/string.h index ccdef751..bf44868c 100644 --- a/frozen/string.h +++ b/frozen/string.h @@ -28,6 +28,7 @@ #include "frozen/bits/hash_string.h" #include "frozen/bits/version.h" +#include #include #ifdef FROZEN_LETITGO_HAS_STRING_VIEW @@ -61,12 +62,7 @@ template class basic_string { constexpr chr_t operator[](std::size_t i) const { return data_[i]; } constexpr bool operator==(basic_string other) const { - if (size_ != other.size_) - return false; - for (std::size_t i = 0; i < size_; ++i) - if (data_[i] != other.data_[i]) - return false; - return true; + return std::memcmp(data_, other.data_, size_) == 0; } constexpr bool operator<(const basic_string &other) const {