* [Qemu-devel] [PATCH] migration: reduce the count of strlen call
@ 2015-07-13 9:34 Liang Li
2015-07-13 9:51 ` Amit Shah
2015-07-15 7:42 ` Juan Quintela
0 siblings, 2 replies; 3+ messages in thread
From: Liang Li @ 2015-07-13 9:34 UTC (permalink / raw)
To: qemu-devel; +Cc: amit.shah, Liang Li, dgilbert, quintela
'strlen' is called three times in 'save_page_header', it's
inefficient.
Signed-off-by: Liang Li <liang.z.li@intel.com>
---
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;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] migration: reduce the count of strlen call
2015-07-13 9:34 [Qemu-devel] [PATCH] migration: reduce the count of strlen call Liang Li
@ 2015-07-13 9:51 ` Amit Shah
2015-07-15 7:42 ` Juan Quintela
1 sibling, 0 replies; 3+ messages in thread
From: Amit Shah @ 2015-07-13 9:51 UTC (permalink / raw)
To: Liang Li; +Cc: qemu-devel, dgilbert, quintela
On (Mon) 13 Jul 2015 [17:34:10], Liang Li wrote:
> 'strlen' is called three times in 'save_page_header', it's
> inefficient.
>
> Signed-off-by: Liang Li <liang.z.li@intel.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Amit
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] migration: reduce the count of strlen call
2015-07-13 9:34 [Qemu-devel] [PATCH] migration: reduce the count of strlen call Liang Li
2015-07-13 9:51 ` Amit Shah
@ 2015-07-15 7:42 ` Juan Quintela
1 sibling, 0 replies; 3+ messages in thread
From: Juan Quintela @ 2015-07-15 7:42 UTC (permalink / raw)
To: Liang Li; +Cc: amit.shah, qemu-devel, dgilbert
Liang Li <liang.z.li@intel.com> wrote:
> '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>
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;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-15 7:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-13 9:34 [Qemu-devel] [PATCH] migration: reduce the count of strlen call Liang Li
2015-07-13 9:51 ` Amit Shah
2015-07-15 7:42 ` Juan Quintela
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).