ladybird/Userland/Libraries/LibRegex/RegexBytecodeStreamOptimizer.h
Ali Mohammad Pur 97a333608e LibRegex: Make codegen+optimisation for alternatives much faster
Just a little thinking outside the box, and we can now parse and
optimise a million copies of "a|" chained together in just a second :^)
2022-02-20 11:53:59 +01:00

22 lines
497 B
C++

/*
* Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Forward.h"
#include <AK/Vector.h>
namespace regex {
class Optimizer {
public:
static void append_alternation(ByteCode& target, ByteCode&& left, ByteCode&& right);
static void append_alternation(ByteCode& target, Span<ByteCode> alternatives);
static void append_character_class(ByteCode& target, Vector<CompareTypeAndValuePair>&& pairs);
};
}