qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Wei Yang <richardw.yang@linux.intel.com>
Cc: qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] cutils: remove one unnecessary pointer operation
Date: Tue, 11 Jun 2019 18:49:54 +0100	[thread overview]
Message-ID: <20190611174954.GI2777@work-vm> (raw)
In-Reply-To: <20190610030852.16039-2-richardw.yang@linux.intel.com>

* Wei Yang (richardw.yang@linux.intel.com) wrote:
> Since we will not operate on the next address pointed by out, it is not
> necessary to do addition on it.
> 
> After removing the operation, the function size reduced 16/18 bytes.

For me with a -O3 it didn't make any difference - the compiler was
already smart enough to spot it, but it is correct.


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  util/cutils.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/util/cutils.c b/util/cutils.c
> index 9aacc422ca..1933a68da5 100644
> --- a/util/cutils.c
> +++ b/util/cutils.c
> @@ -754,11 +754,11 @@ int uleb128_encode_small(uint8_t *out, uint32_t n)
>  {
>      g_assert(n <= 0x3fff);
>      if (n < 0x80) {
> -        *out++ = n;
> +        *out = n;
>          return 1;
>      } else {
>          *out++ = (n & 0x7f) | 0x80;
> -        *out++ = n >> 7;
> +        *out = n >> 7;
>          return 2;
>      }
>  }
> @@ -766,7 +766,7 @@ int uleb128_encode_small(uint8_t *out, uint32_t n)
>  int uleb128_decode_small(const uint8_t *in, uint32_t *n)
>  {
>      if (!(*in & 0x80)) {
> -        *n = *in++;
> +        *n = *in;
>          return 1;
>      } else {
>          *n = *in++ & 0x7f;
> @@ -774,7 +774,7 @@ int uleb128_decode_small(const uint8_t *in, uint32_t *n)
>          if (*in & 0x80) {
>              return -1;
>          }
> -        *n |= *in++ << 7;
> +        *n |= *in << 7;
>          return 2;
>      }
>  }
> -- 
> 2.19.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


  reply	other threads:[~2019-06-11 17:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10  3:08 [Qemu-devel] [PATCH 0/2] migration/xbzrle: make xbzrle_encode_buffer little easier Wei Yang
2019-06-10  3:08 ` [Qemu-devel] [PATCH 1/2] cutils: remove one unnecessary pointer operation Wei Yang
2019-06-11 17:49   ` Dr. David Alan Gilbert [this message]
2019-06-11 22:10     ` Wei Yang
2019-06-12 10:17   ` Juan Quintela
2019-06-10  3:08 ` [Qemu-devel] [PATCH 2/2] migration/xbzrle: make xbzrle_encode_buffer little easier to read Wei Yang
2019-06-11 17:59   ` Dr. David Alan Gilbert
2019-06-12  0:33     ` Wei Yang
2019-06-12  1:30     ` Wei Yang
2019-06-12 10:29     ` Juan Quintela
2019-06-12 15:02       ` Wei Yang

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=20190611174954.GI2777@work-vm \
    --to=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=richardw.yang@linux.intel.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;
as well as URLs for NNTP newsgroup(s).