refactor: remove set_location

This commit is contained in:
ToruNiina
2024-10-18 00:35:13 +09:00
parent 7f6c574ff5
commit 1ba90bc505
3 changed files with 2 additions and 27 deletions

View File

@@ -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
{

View File

@@ -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());

View File

@@ -3459,7 +3459,7 @@ parse_impl(std::vector<location::char_type> 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<location::char_type> 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;
}
}