lkml.org 
[lkml]   [2019]   [Dec]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v8 10/13] exfat: add nls operations
From
Date
On Tue, 2019-12-31 at 15:23 +0100, Markus Elfring wrote:
> …
> > +++ b/fs/exfat/nls.c
> …
> > +int exfat_nls_cmp_uniname(struct super_block *sb, unsigned short *a,
> > + unsigned short *b)
> > +{
> > + int i;
> > +
> > + for (i = 0; i < MAX_NAME_LENGTH; i++, a++, b++) {
> > + if (exfat_nls_upper(sb, *a) != exfat_nls_upper(sb, *b))
>
> Can it matter to compare run time characteristics with the following
> code variant?
>
> + for (i = 0; i < MAX_NAME_LENGTH; i++) {
> + if (exfat_nls_upper(sb, a[i]) != exfat_nls_upper(sb, b[i]))

Markus, try comparing the object code produced by the compiler first,
it's likely identical.

If this is actually a performance sensitive path, it might improve
runtime by having 2 code paths to avoid the testing of
sbi->options.case_sensitive for each u16 value in the array.

Something like: (uncompiled, untested, written in email client)

static inline
unsigned short exfat_sbi_upper(struct exfat_sb_info *sbi, unsigned short a)
{
if (sbi->vol_utbl[a])
return sbi->vol_utbl[a];
return a;
}

int exfat_nls_cmp_uniname(struct super_block *sb,
unsigned short *a,
unsigned short *b)
{
int i;
struct exfat_sb_info *sbi = EXFAT_SB(sb);

if (!sbi->options.case_sensitive) {
for (i = 0; i < MAX_NAME_LENGTH; i++, a++, b++) {
if (exfat_sbi_upper(sbi, *a) != exfat_sbi_upper(sbi, *b))
return 1;
if (*a == 0x0)
return 0;
}
} else {
for (i = 0; i < MAX_NAME_LENGTH; i++, a++, b++) {
if (*a != *b)
return 1;
if (*a == 0x0)
return 0;
}
}

return 0;
}


\
 
 \ /
  Last update: 2019-12-31 19:03    [W:0.057 / U:2.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site