public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
	Proxmox Datacenter Manager development discussion
	<pdm-devel@lists.proxmox.com>
Subject: Re: [pdm-devel] [PATCH datacenter-manager] server: api: resources: make search terms (ascii) case insensitive
Date: Tue, 16 Sep 2025 11:45:45 +0200	[thread overview]
Message-ID: <42528b92-3187-40ec-8c18-08581ee9f471@proxmox.com> (raw)
In-Reply-To: <26a86759-8d6a-4253-90a1-6a45272058f2@proxmox.com>



On 9/15/25 4:41 PM, Thomas Lamprecht wrote:
> 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.
> 

ok, after re-thinking this, i believe it makes sense to just use
to_lowercase here after all. you're right that the terms/values
are not that long, and mostly ascii anyway so the overhead
should be negligible vs the downside of potentially not matching
correctly should we include any non-ascii data here..

>>
>> 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.


not super sure what you're proposing here, do you mean we should
introduce these helpers in addition to using the category matches
or instead of?

the reason why i used the category matchers here (besides reusing the 
code) is to get a consistent behavior for the search itself
(contains vs starts_with) for the various fields, so i'd like to
to use them in any case

with that in mind, i don't think the helpers you propose have
much value, as they'll only be used in one place each


_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


      reply	other threads:[~2025-09-16  9:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-12  9:30 Dominik Csapak
2025-09-15 14:41 ` Thomas Lamprecht
2025-09-16  9:45   ` Dominik Csapak [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42528b92-3187-40ec-8c18-08581ee9f471@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal