Commit Graph

2 Commits

Author SHA1 Message Date
Nico Weber
b46bb32584 LibLocale: Make Segmenter store segment boundaries
Instead of recomputing boundaries on every iteration, this now
computes boundaries once and then searches that vector.

This is still O(n^2) for now, but already much faster (at the expense
of using O(n) memory): `BenchmarkSegmenter.for_each_boundary` stays
at around 3ms, but `forward` and `backward` go from ~13s to ~60ms
on my system.
2024-11-27 10:42:35 -05:00
Nico Weber
71ea3c53a6 LibLocale: Add Segmenter.h
This is aspirationally in LibLocale in hopes that it does
locale-dependent segmentation one day.

For now, it just wraps LibUnicode's Segmentation.h.

Everything except Segmenter.cpp are from the first commit of
LadybirdBrowser/ladybird#218, by trflynn.

Co-authored-by: Tim Flynn <trflynn89@serenityos.org>
2024-11-26 13:50:49 -05:00