public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Denys Vlasenko <vda.linux@googlemail.com>
Cc: linux-kernel@vger.kernel.org,
	OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Subject: Re: [PATCH] fat: don't use custom hex_to_bin()
Date: Fri, 23 Sep 2011 15:11:21 +0300	[thread overview]
Message-ID: <1316779881.2676.44.camel@smile> (raw)
In-Reply-To: <CAK1hOcNus4RKQOF=eivuCXFEM5Lqb+jBdOD4YrMA_5bL2EB6yA@mail.gmail.com>

On Fri, 2011-09-23 at 14:05 +0200, Denys Vlasenko wrote: 
> On Fri, Sep 23, 2011 at 1:32 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> > ---
> >  fs/fat/namei_vfat.c |   22 ++++++----------------
> >  1 files changed, 6 insertions(+), 16 deletions(-)
> >
> > diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
> > index bb3f29c..09cec4c 100644
> > --- a/fs/fat/namei_vfat.c
> > +++ b/fs/fat/namei_vfat.c
> > @@ -21,6 +21,8 @@
> >  #include <linux/slab.h>
> >  #include <linux/buffer_head.h>
> >  #include <linux/namei.h>
> > +#include <linux/kernel.h>
> > +
> >  #include "fat.h"
> >
> >  /*
> > @@ -505,7 +507,6 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
> >             struct nls_table *nls)
> >  {
> >        const unsigned char *ip;
> > -       unsigned char nc;
> >        unsigned char *op;
> >        unsigned int ec;
> >        int i, k, fill;
> > @@ -530,21 +531,10 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
> >                                                return -EINVAL;
> >                                        ec = 0;
> >                                        for (k = 1; k < 5; k++) {
> > -                                               nc = ip[k];
> > -                                               ec <<= 4;
> > -                                               if (nc >= '0' && nc <= '9') {
> > -                                                       ec |= nc - '0';
> > -                                                       continue;
> > -                                               }
> > -                                               if (nc >= 'a' && nc <= 'f') {
> > -                                                       ec |= nc - ('a' - 10);
> > -                                                       continue;
> > -                                               }
> > -                                               if (nc >= 'A' && nc <= 'F') {
> > -                                                       ec |= nc - ('A' - 10);
> > -                                                       continue;
> > -                                               }
> > -                                               return -EINVAL;
> > +                                               int val = hex_to_bin(ip[k]);
> > +                                               if (val < 0)
> > +                                                       return -EINVAL;
> > +                                               ec = (ec << 4) | val;
> >                                        }
> >                                        *op++ = ec & 0xFF;
> >                                        *op++ = ec >> 8;
> 
> Function call per byte?
4 times in our case per 16 bit.

> That's expensive!
By the way, you can do those optimizations across the kernel. There are
dozens of places where one or few bytes are converted per half-byte.

> Can't we have a function which converts many sequential bytes?
We have one, but it doesn't return any error. We could wait until Mimi
integrates his patch series.


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  reply	other threads:[~2011-09-23 12:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-23 11:32 [PATCH] alsa: 6fire: don't use custom hex_to_bin() Andy Shevchenko
2011-09-23 11:32 ` [PATCH] fat: " Andy Shevchenko
2011-09-23 12:05   ` Denys Vlasenko
2011-09-23 12:11     ` Andy Shevchenko [this message]
2011-09-27 11:48     ` [PATCHv2] " Andy Shevchenko
2011-09-27 17:19       ` OGAWA Hirofumi
2011-09-27 17:52         ` Andy Shevchenko
2011-09-27 18:06         ` Andy Shevchenko
2011-09-27 23:15           ` OGAWA Hirofumi
2011-09-29 13:07             ` Andy Shevchenko
2011-09-29 14:43               ` OGAWA Hirofumi
2011-09-29 14:54                 ` Andy Shevchenko
2011-09-29 15:19                   ` OGAWA Hirofumi
2011-09-29 15:10                 ` [PATCHv4] " Andy Shevchenko
2011-09-29 15:37                   ` Joe Perches
2011-09-29 18:27                     ` OGAWA Hirofumi
2011-09-29 18:41                       ` Joe Perches
2011-09-29 19:35                         ` OGAWA Hirofumi
2011-09-29 13:15             ` [PATCHv3] " Andy Shevchenko
2011-09-29 14:51               ` OGAWA Hirofumi
2011-09-23 13:22 ` [PATCH] alsa: 6fire: " Takashi Iwai

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=1316779881.2676.44.camel@smile \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vda.linux@googlemail.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