mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Make hfa::match not need to walk a string twice
Currently hfa::match calls hfa::match_len to do matching. However this requires walking the input string twice. Instead provide a match routine for input that is supposed to terminate at a given input character. Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-By: Steve Beattie <sbeattie@ubuntu.com>
This commit is contained in:
parent
3ff8b4d19a
commit
f561b8cdfe
2 changed files with 10 additions and 1 deletions
|
@ -276,9 +276,17 @@ State *DFA::match_len(State *state, const char *str, size_t len)
|
|||
return state;
|
||||
}
|
||||
|
||||
State *DFA::match_until(State *state, const char *str, const char term)
|
||||
{
|
||||
while (*str != term)
|
||||
state = state->next(*str++);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
State *DFA::match(const char *str)
|
||||
{
|
||||
return match_len(start, str, strlen(str));
|
||||
return match_until(start, str, 0);
|
||||
}
|
||||
|
||||
void DFA::dump_uniq_perms(const char *s)
|
||||
|
|
|
@ -349,6 +349,7 @@ public:
|
|||
virtual ~DFA();
|
||||
|
||||
State *match_len(State *state, const char *str, size_t len);
|
||||
State *match_until(State *state, const char *str, const char term);
|
||||
State *match(const char *str);
|
||||
|
||||
void remove_unreachable(dfaflags_t flags);
|
||||
|
|
Loading…
Add table
Reference in a new issue