[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] migration: reduce the count of strlen call
From: |
Juan Quintela |
Subject: |
Re: [Qemu-devel] [PATCH] migration: reduce the count of strlen call |
Date: |
Wed, 15 Jul 2015 09:42:59 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Liang Li <address@hidden> wrote:
> 'strlen' is called three times in 'save_page_header', it's
> inefficient.
>
> Signed-off-by: Liang Li <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Applied
> ---
> migration/ram.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index 1e58cd3..7f007e6 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -382,16 +382,16 @@ void migrate_compress_threads_create(void)
> */
> static size_t save_page_header(QEMUFile *f, RAMBlock *block, ram_addr_t
> offset)
> {
> - size_t size;
> + size_t size, len;
>
> qemu_put_be64(f, offset);
> size = 8;
>
> if (!(offset & RAM_SAVE_FLAG_CONTINUE)) {
> - qemu_put_byte(f, strlen(block->idstr));
> - qemu_put_buffer(f, (uint8_t *)block->idstr,
> - strlen(block->idstr));
> - size += 1 + strlen(block->idstr);
> + len = strlen(block->idstr);
> + qemu_put_byte(f, len);
> + qemu_put_buffer(f, (uint8_t *)block->idstr, len);
> + size += 1 + len;
> }
> return size;
> }