From 1ba90bc505ac7ff0074a30658ae4b52408a069c1 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Fri, 18 Oct 2024 00:35:13 +0900 Subject: [PATCH] refactor: remove set_location --- include/toml11/fwd/location_fwd.hpp | 1 - include/toml11/impl/location_impl.hpp | 24 ------------------------ include/toml11/parser.hpp | 4 ++-- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/include/toml11/fwd/location_fwd.hpp b/include/toml11/fwd/location_fwd.hpp index f6dbfdb..650381f 100644 --- a/include/toml11/fwd/location_fwd.hpp +++ b/include/toml11/fwd/location_fwd.hpp @@ -54,7 +54,6 @@ class location { return this->location_; } - void set_location(const std::size_t loc) noexcept; std::size_t line_number() const noexcept { diff --git a/include/toml11/impl/location_impl.hpp b/include/toml11/impl/location_impl.hpp index 19c418a..7be3d18 100644 --- a/include/toml11/impl/location_impl.hpp +++ b/include/toml11/impl/location_impl.hpp @@ -66,30 +66,6 @@ TOML11_INLINE location::char_type location::peek() } } -TOML11_INLINE void location::set_location(const std::size_t loc) noexcept -{ - if(this->location_ == loc) - { - return ; - } - - if(loc == 0) - { - this->line_number_ = 1; - } - else if(this->location_ < loc) - { - const auto d = loc - this->location_; - this->advance_line_number(d); - } - else - { - const auto d = this->location_ - loc; - this->retrace_line_number(d); - } - this->location_ = loc; -} - TOML11_INLINE std::string location::get_line() const { assert(this->is_ok()); diff --git a/include/toml11/parser.hpp b/include/toml11/parser.hpp index 6d14731..3915650 100644 --- a/include/toml11/parser.hpp +++ b/include/toml11/parser.hpp @@ -3459,7 +3459,7 @@ parse_impl(std::vector cs, std::string fname, const spec& s // skip BOM if found if(loc.source()->size() >= 3) { - auto first = loc.get_location(); + auto first = loc; const auto c0 = loc.current(); loc.advance(); const auto c1 = loc.current(); loc.advance(); @@ -3468,7 +3468,7 @@ parse_impl(std::vector cs, std::string fname, const spec& s const auto bom_found = (c0 == 0xEF) && (c1 == 0xBB) && (c2 == 0xBF); if( ! bom_found) { - loc.set_location(first); + loc = first; } }