[Lazarus] unit Masks vs. unit FPMasks
Juha Manninen
juha.manninen62 at gmail.com
Wed Feb 24 09:11:15 CET 2021
On Wed, Feb 24, 2021 at 12:08 AM Bart via lazarus <
lazarus at lists.lazarus-ide.org> wrote:
> TMask (unit masks) deals with masks with wildcards (*,? and sets of
> single byte chars).
> It is mainly used for matching filenames (similar to the Path supplied
> to FindFirst).
>
> TMaskEdit gives you the possibility to constrain user input to almost
> anything you like,
> Can be used for e.g. ZIP codes, only numbers etc.
>
TMask also supports ranges and sets. See the unit test.
Eg. '[a-b]', '[!a-b]', '[abc]', '[0-9]'
Now I found documentation for TCustomMaskEdit.EditMask. It explains the
syntax and it looks like the MaskUtils syntax.
It was documented, good! I missed it earlier.
I know filename wildcards and I know regular expressions. Now learning this
Mask thingy...
As you have pointed out before, the GetCodePoint function in the Masks
> unit needs overhoaling.
>
It is much worse than that!
Yes, GetCodePoint does its own nested loops and useless copies.
But then it and other UTF8...() functions are called inside a loop,
effectively causing many nested loops.
The scalability is maybe O(n^3) or O(n^4).
José Mejuto's Mask unit looks promising. He mentioned in a private mail
(which should be public IMO, no deep secrets there) that a pattern
* "*something*to*write*here*""which with current mask it takes a lot of
time to be processed. If matchable string is of more than 200 chars long it
could take seconds to be resolved. My classes are typically O(n)."*
Many seconds in a modern computer is a lot.
(It is the same as in TMaskEdit, but that only reacts to user input
> with strings <=255 chars, so speed is not required there: I'ld love to
> see someone typing faster that the code in TMaskEdit calculates what
> needs to be done.)
>
True, but the code should be cleaned anyway and maybe reuse some other code.
Code has aesthetic values, too.
Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20210224/a192df4c/attachment.html>
More information about the lazarus
mailing list