All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Stefan Weil <weil@mail.berlios.de>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Christoph Egger <Christoph.Egger@amd.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [RFC][PATCH] signrom: Speed up checksum calculation
Date: Tue, 24 Jan 2012 09:39:53 +0100	[thread overview]
Message-ID: <4F1E6E59.6060405@redhat.com> (raw)
In-Reply-To: <4F1DA926.4000709@siemens.com>

On 01/23/2012 07:38 PM, Jan Kiszka wrote:
>   nums=`od -A n -t u1 -v -N $size "$1"`
> -for i in ${nums}; do
> -    # add each byte's value to sum
> -    sum=`expr \( $sum + $i \) % 256`
> -done
> -
> -sum=$(( (256 - $sum) % 256 ))

We have a bashism here, so why not do

   sum=$(( ($sum + $i) % 256 ))

and do the same with a one-line patch (two line if you change the header 
to #!/bin/bash)?  It should be just as fast as awk.

Paolo

      parent reply	other threads:[~2012-01-24  8:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-23 18:38 [Qemu-devel] [RFC][PATCH] signrom: Speed up checksum calculation Jan Kiszka
2012-01-23 19:16 ` Stefan Weil
2012-01-23 19:19   ` Jan Kiszka
2012-01-23 19:25     ` Stefan Weil
2012-01-23 20:08       ` Anthony Liguori
2012-01-23 20:32         ` Jan Kiszka
2012-01-23 20:37           ` Anthony Liguori
2012-01-23 21:32             ` Stefan Weil
2012-01-24  9:43             ` Andreas Färber
2012-01-24  8:18         ` Paolo Bonzini
2012-01-24 10:18   ` Christoph Egger
2012-01-24  8:39 ` Paolo Bonzini [this message]

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=4F1E6E59.6060405@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=Christoph.Egger@amd.com \
    --cc=agraf@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    --cc=weil@mail.berlios.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.