aboutsummaryrefslogtreecommitdiff
path: root/core/strings/ascii_set.odin
blob: 582049eee819c5d2f572e4759141dda7bd211412 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//+private
package strings

import "core:unicode/utf8"

Ascii_Set :: distinct [8]u32

ascii_set_make :: proc(chars: string) -> (as: Ascii_Set, ok: bool) #no_bounds_check {
	for i in 0..<len(chars) {
		c := chars[i]
		if c >= utf8.RUNE_SELF {
			return
		}
		as[c>>5] |= 1 << uint(c&31)
	}
	ok = true
	return
}

ascii_set_contains :: proc(as: Ascii_Set, c: byte) -> bool #no_bounds_check {
	return as[c>>5] & (1<<(c&31)) != 0
}