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

From: Neil Horman
Date: Tue Sep 11 2012 - 11:33:44 EST


On Tue, Sep 11, 2012 at 12:42:23PM +0100, David Laight wrote:
> > - 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/