mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 15:30:52 +01:00
ircd:Ⓜ️🆔 Fail boolean validators faster on empty id.
This commit is contained in:
parent
44d105b1ba
commit
ccf9f87e2a
1 changed files with 10 additions and 2 deletions
12
ircd/m_id.cc
12
ircd/m_id.cc
|
@ -674,6 +674,9 @@ ircd::m::valid(const id::sigil &sigil,
|
||||||
const string_view &id)
|
const string_view &id)
|
||||||
noexcept try
|
noexcept try
|
||||||
{
|
{
|
||||||
|
if(empty(id))
|
||||||
|
return false;
|
||||||
|
|
||||||
validate(sigil, id);
|
validate(sigil, id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -697,7 +700,10 @@ noexcept try
|
||||||
start + std::min(size(id), id::MAX_SIZE)
|
start + std::min(size(id), id::MAX_SIZE)
|
||||||
};
|
};
|
||||||
|
|
||||||
return id.at(0) == sigil && qi::parse(start, stop, test) && start == stop;
|
return !empty(id) &&
|
||||||
|
id.at(0) == sigil &&
|
||||||
|
qi::parse(start, stop, test) &&
|
||||||
|
start == stop;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -719,7 +725,9 @@ noexcept try
|
||||||
start + std::min(size(id), id::MAX_SIZE)
|
start + std::min(size(id), id::MAX_SIZE)
|
||||||
};
|
};
|
||||||
|
|
||||||
return id.at(0) == sigil && qi::parse(start, stop, test);
|
return !empty(id) &&
|
||||||
|
id.at(0) == sigil &&
|
||||||
|
qi::parse(start, stop, test);
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue