[libc-commits] [libc] [libc][regex] Add 256-bit ByteSet and '.' wildcard (PR #233561)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Mon Oct 19 15:24:53 PDT 2026
================
@@ -222,6 +227,51 @@ ErrorOr<ExprId> ExprPool::make_lit(char c) {
return intern(Expr::make_literal(c));
}
+ErrorOr<ExprId> ExprPool::make_byte_set(const ByteSet &bs) {
+ size_t count = 0;
+ size_t last_bit = 0;
+ for (size_t b = 0; b < BYTE_SET_BITS; ++b) {
+ if (bs.test(b)) {
+ ++count;
+ last_bit = b;
+ }
+ }
+ if (count == 0)
+ return empty_set();
+ if (count == 1)
+ return make_lit(static_cast<char>(last_bit));
+
+ uint32_t bs_id = 0;
+ for (const ByteSet &existing : active_byte_sets()) {
+ if (existing == bs)
+ return intern(Expr::make_byte_set(bs_id));
+ ++bs_id;
+ }
+
+ if (byte_set_count == byte_sets.size()) {
+ size_t new_cap =
+ byte_sets.empty() ? INITIAL_BYTE_SETS_CAPACITY : byte_sets.size() * 2;
----------------
michaelrj-google wrote:
nit: iirc there's a scaling factor constant, should that be used here instead of just 2?
https://github.com/llvm/llvm-project/pull/233561
More information about the libc-commits
mailing list