aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiang Li <liang.z.li@intel.com>2015-07-13 17:34:10 +0800
committerJuan Quintela <quintela@redhat.com>2015-07-15 12:21:28 +0200
commit9f5f380b54d6ad80cf35d93c8cd71c8d7a1b52b7 (patch)
tree83f006700918d86365571f29873403fa3f9c04a0
parent48212d87d6655b029231d830a77983c21552fe49 (diff)
downloadqemu-9f5f380b54d6ad80cf35d93c8cd71c8d7a1b52b7.zip
qemu-9f5f380b54d6ad80cf35d93c8cd71c8d7a1b52b7.tar.gz
qemu-9f5f380b54d6ad80cf35d93c8cd71c8d7a1b52b7.tar.bz2
migration: reduce the count of strlen call
'strlen' is called three times in 'save_page_header', it's inefficient. Signed-off-by: Liang Li <liang.z.li@intel.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
-rw-r--r--migration/ram.c10
1 files 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;
}