Skip to content

Commit

Permalink
migration: reduce the count of strlen call
Browse files Browse the repository at this point in the history
'strlen' is called three times in 'save_page_header', it's
inefficient.

Signed-off-by: Liang Li <[email protected]>
Reviewed-by: Juan Quintela <[email protected]>
Reviewed-by: Amit Shah <[email protected]>
Signed-off-by: Juan Quintela <[email protected]>
  • Loading branch information
Liang Li authored and Juan Quintela committed Jul 15, 2015
1 parent 48212d8 commit 9f5f380
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions migration/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9f5f380

Please sign in to comment.