diff mbox

[v1] net/sunrpc/cache: simplify code by using hex_pack_byte()

Message ID 1386856161-29889-1-git-send-email-andriy.shevchenko@linux.intel.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Andy Shevchenko Dec. 12, 2013, 1:49 p.m. UTC
hex_pack_byte() is a fast way to convert a byte in its ASCII representation. We
may use it instead of custom approach.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 net/sunrpc/cache.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

J. Bruce Fields Dec. 12, 2013, 4 p.m. UTC | #1
On Thu, Dec 12, 2013 at 03:49:21PM +0200, Andy Shevchenko wrote:
> hex_pack_byte() is a fast way to convert a byte in its ASCII representation. We
> may use it instead of custom approach.

Thanks, I'll take that through the nfsd tree for 3.14.

--b.

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  net/sunrpc/cache.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
> index a72de07..0877db0 100644
> --- a/net/sunrpc/cache.c
> +++ b/net/sunrpc/cache.c
> @@ -1111,9 +1111,7 @@ void qword_addhex(char **bpp, int *lp, char *buf, int blen)
>  		*bp++ = 'x';
>  		len -= 2;
>  		while (blen && len >= 2) {
> -			unsigned char c = *buf++;
> -			*bp++ = '0' + ((c&0xf0)>>4) + (c>=0xa0)*('a'-'9'-1);
> -			*bp++ = '0' + (c&0x0f) + ((c&0x0f)>=0x0a)*('a'-'9'-1);
> +			bp = hex_byte_pack(bp, *buf++);
>  			len -= 2;
>  			blen--;
>  		}
> -- 
> 1.8.4.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index a72de07..0877db0 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1111,9 +1111,7 @@  void qword_addhex(char **bpp, int *lp, char *buf, int blen)
 		*bp++ = 'x';
 		len -= 2;
 		while (blen && len >= 2) {
-			unsigned char c = *buf++;
-			*bp++ = '0' + ((c&0xf0)>>4) + (c>=0xa0)*('a'-'9'-1);
-			*bp++ = '0' + (c&0x0f) + ((c&0x0f)>=0x0a)*('a'-'9'-1);
+			bp = hex_byte_pack(bp, *buf++);
 			len -= 2;
 			blen--;
 		}