[pdm-devel] [PATCH datacenter-manager] server: api: resources: make search terms (ascii) case insensitive

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Sep 15 16:41:29 CEST 2025


Am 12.09.25 um 11:31 schrieb Dominik Csapak:
> by converting both the values and the terms to (ascii) lower case.
> 
> Making the search case insensitive seems more intuitive, since most
> searches i could find behave this way (except e.g. in editors)
> 
> Since all values are currently ascii only, and this is faster than
> `to_lowercase` using `to_ascii_lowercase` seems better here.

But is it really faster as long as the data only contains ascii?
Checking the implementation it still does ascii first and only a
more elaborate conversion if there's anything left over. Sure, more
work than here, but for the data sizes here that range mostly in the
tens to at max hundreds of bytes, besides some outlier.
So not sure if we should add limitations here, as this also affects
simple umlauts or characters with accents, which are quite common.

That said, most things we currently match are restricted to ascii,
so with a comment that tries to avoid copying this over for something
that is not certain to be ascii (like free form description/notes)
in the future, I'd be fine with doing it your proposed way.

> 
> Also noticed that some matches can be replaced with the respective
> MatchCategory matches, so we don't have to repeat this pattern
> everywhere.

Great, but might be even better to add some dedicated helpers private
to this module for that, like (rather verbose):

contains_case_insensitive

starts_with_case_insensitive

As you still need to pass all arguments explicitly anyway (like e.g.
"remote"), so it's not like reusing this gives you any type saftey
over a simple helper, while as being proposed it abstracts away the
simple thing that happens under the hood, so IMO not a very good kind
of abstraction/reuse (but certainly a matter of taste to a degree).
Creating a simple trait for the search and implementing it for &str
in this module might be an alternative to make it a bit more ergonomic
to rust, but not sure if that's worth it (or better), just wanted to
throw out the idea.




More information about the pdm-devel mailing list