Thread (5 messages) flat view 5 messages, 3 authors, 2012-09-12

Re: [PATCH 2/2] netprio_cgroup: Optimize the priomap copy loop slightly

From: Neil Horman <nhorman@tuxdriver.com>
Date: 2012-09-11 15:33:43
Also in: lkml

On Tue, Sep 11, 2012 at 12:42:23PM +0100, David Laight wrote:
quoted
-	for (i = 0;
-	     old_priomap && (i < old_priomap->priomap_len);
-	     i++)
-		new_priomap->priomap[i] = old_priomap->priomap[i];
+	if (old_priomap) {
+		old_len = old_priomap->priomap_len;
+
+		for (i = 0; i < old_len; i++)
+			new_priomap->priomap[i] = old_priomap->priomap[i];
+	}
Or:
	memcpy(new_priomap->priomap, old_priomap->priomap,
		old_priomap->priomap_len * sizeof old_priomap->priomap[0]);

	David
Yes, the memcpy would be better here.
Neil
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help