提交 9f5f380b 编写于 作者: L Liang Li 提交者: Juan Quintela

migration: reduce the count of strlen call

'strlen' is called three times in 'save_page_header', it's
inefficient.
Signed-off-by: NLiang Li <liang.z.li@intel.com>
Reviewed-by: NJuan Quintela <quintela@redhat.com>
Reviewed-by: NAmit Shah <amit.shah@redhat.com>
Signed-off-by: NJuan Quintela <quintela@redhat.com>
上级 48212d87
...@@ -382,16 +382,16 @@ void migrate_compress_threads_create(void) ...@@ -382,16 +382,16 @@ void migrate_compress_threads_create(void)
*/ */
static size_t save_page_header(QEMUFile *f, RAMBlock *block, ram_addr_t offset) 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); qemu_put_be64(f, offset);
size = 8; size = 8;
if (!(offset & RAM_SAVE_FLAG_CONTINUE)) { if (!(offset & RAM_SAVE_FLAG_CONTINUE)) {
qemu_put_byte(f, strlen(block->idstr)); len = strlen(block->idstr);
qemu_put_buffer(f, (uint8_t *)block->idstr, qemu_put_byte(f, len);
strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, len);
size += 1 + strlen(block->idstr); size += 1 + len;
} }
return size; return size;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册