qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC][PATCH] signrom: Speed up checksum calculation


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [RFC][PATCH] signrom: Speed up checksum calculation
Date: Tue, 24 Jan 2012 09:39:53 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]