Move away from macro, get slight perf boost with hand rolled compare
This commit is contained in:
parent
95e119fffe
commit
5f402e71dd
@ -438,15 +438,20 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
|
||||
/// Reads a symbol group from input if it matches the parameter, without skipping initial whitespace
|
||||
#define Symbol_(t_s, len) \
|
||||
( \
|
||||
m_position.remaining() >= len \
|
||||
? std::memcmp(t_s, &(*m_position), len) == 0 \
|
||||
? ((m_position += len),true) \
|
||||
:false \
|
||||
:false \
|
||||
)
|
||||
/// Reads a symbol group from input if it matches the parameter, without skipping initial whitespace
|
||||
inline bool Symbol_(const char *t_s, const size_t len)
|
||||
{
|
||||
if (m_position.remaining() >= len) {
|
||||
const char *file_pos = &(*m_position);
|
||||
for (size_t pos = 0; pos < len; ++pos)
|
||||
{
|
||||
if (t_s[pos] != file_pos[pos]) { return false; }
|
||||
}
|
||||
m_position += len;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Skips any multi-line or single-line comment
|
||||
bool SkipComment() {
|
||||
@ -2540,8 +2545,6 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
#undef Symbol_
|
||||
|
||||
#if defined(CHAISCRIPT_MSVC) && defined(CHAISCRIPT_PUSHED_MIN_MAX)
|
||||
#undef CHAISCRIPT_PUSHED_MIN_MAX
|
||||
#pragma pop_macro("min")
|
||||
|
Loading…
x
Reference in New Issue
Block a user