From: David Timber <dxdt@dev.snart.me>
To: "Yuezhang.Mo@sony.com" <Yuezhang.Mo@sony.com>,
Namjae Jeon <linkinjeon@kernel.org>,
Sungjong Seo <sj1557.seo@samsung.com>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH v2 2/4] exfat: optimise and refactor filename up-case conversion
Date: Mon, 11 May 2026 07:58:40 +0900 [thread overview]
Message-ID: <9a4f44b0-ec1a-4bb0-bd58-37f470b6a595@dev.snart.me> (raw)
In-Reply-To: <PUZPR04MB631684B809F703C8D62D3B59813C2@PUZPR04MB6316.apcprd04.prod.outlook.com>
On 5/7/26 21:03, Yuezhang.Mo@sony.com wrote:
>> +static inline bool exfat_illegal_chr(const unsigned short wchar)
>> {
>> - while (*str) {
>> - if (*(str++) == wchar)
>> - return str;
>> + switch (wchar) {
>> + /*
>> + * Control characters
>> + *
>> + * This saves some cmp instructions if the compiler does its job correctly
>> + */
>> + case 0x0000: case 0x0001: case 0x0002: case 0x0003:
>> + case 0x0004: case 0x0005: case 0x0006: case 0x0007:
>> + case 0x0008: case 0x0009: case 0x000A: case 0x000B:
>> + case 0x000C: case 0x000D: case 0x000E: case 0x000F:
>> + case 0x0010: case 0x0011: case 0x0012: case 0x0013:
>> + case 0x0014: case 0x0015: case 0x0016: case 0x0017:
>> + case 0x0018: case 0x0019: case 0x001A: case 0x001B:
>> + case 0x001C: case 0x001D: case 0x001E: case 0x001F:
>> +
>> + case 0x0022: /* QUOTATION MARK: (") */
>> + case 0x002A: /* ASTERISK: (*) */
>> + case 0x002F: /* FORWARD SLASH: (/) */
>> + case 0x003A: /* COLON: (:) */
>> + case 0x003C: /* LESS-THAN SIGN: (<) */
>> + case 0x003E: /* GREATER-THAN SIGN: (>) */
>> + case 0x003F: /* QUESTION MARK: (?) */
>> + case 0x005C: /* BACKSLASH: (\) */
>> + case 0x007C: /* PIPE: (|) */
>> + return true;
> For the continuous range 0x0000 to 0x001F, I think it's better to
> handle it like below, which avoids the large jump table, and may be
> just as fast(or even faster).
>
> default:
> return wchar < 0x0020;
I guess you're right.
That costs one extra cmp instructions but still fits under a cache
granularity on modern hardware(64 bytes) so it wouldn't really show up
in profiling. Better to avoid risking compiler mindlessly producing a
huge jump table.
Either way, still a win since the processor no longer has to iterate
over the array.
next prev parent reply other threads:[~2026-05-10 22:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 12:31 [PATCH v2 0/4] exfat: memory optimisations and stringent integrity checks for up-case table David Timber
2026-05-05 12:31 ` [PATCH v2 1/4] exfat: use upcase_ptable and upcase_range_info to reduce memory footprint David Timber
2026-05-07 12:03 ` Yuezhang.Mo
2026-05-10 22:22 ` David Timber
2026-05-05 12:31 ` [PATCH v2 2/4] exfat: optimise and refactor filename up-case conversion David Timber
2026-05-07 12:03 ` Yuezhang.Mo
2026-05-10 22:58 ` David Timber [this message]
2026-05-05 12:31 ` [PATCH v2 3/4] exfat: add default_upcase option (read-only) David Timber
2026-05-05 12:31 ` [PATCH v2 4/4] exfat: more pedantic upcase table validity check David Timber
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=9a4f44b0-ec1a-4bb0-bd58-37f470b6a595@dev.snart.me \
--to=dxdt@dev.snart.me \
--cc=Yuezhang.Mo@sony.com \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sj1557.seo@samsung.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