diff mbox

[ovs-dev,3/3] dpif-netdev: Reduce code duplication

Message ID 1453930264-111017-3-git-send-email-azhou@ovn.org
State Accepted
Headers show

Commit Message

Andy Zhou Jan. 27, 2016, 9:31 p.m. UTC
Code clean up to reduce code duplication.

Signed-off-by: Andy Zhou <azhou@ovn.org>
---
 lib/dpif-netdev.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Daniele Di Proietto Jan. 28, 2016, 1:01 a.m. UTC | #1
For the series:

Acked-by: Daniele Di Proietto <diproiettod@vmware.com>

I didn't observe any performance regressions.

Thanks!

On 27/01/2016 13:31, "Andy Zhou" <azhou@ovn.org> wrote:

>Code clean up to reduce code duplication.
>
>Signed-off-by: Andy Zhou <azhou@ovn.org>
>---
> lib/dpif-netdev.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
>diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
>index a7e15aa..8d72e27 100644
>--- a/lib/dpif-netdev.c
>+++ b/lib/dpif-netdev.c
>@@ -3178,13 +3178,11 @@ dp_netdev_queue_batches(struct dp_packet *pkt,
> {
>     struct packet_batch *batch = flow->batch;
> 
>-    if (OVS_LIKELY(batch)) {
>-        packet_batch_update(batch, pkt, mf);
>-        return;
>+    if (OVS_UNLIKELY(!batch)) {
>+        batch = &batches[(*n_batches)++];
>+        packet_batch_init(batch, flow);
>     }
> 
>-    batch = &batches[(*n_batches)++];
>-    packet_batch_init(batch, flow);
>     packet_batch_update(batch, pkt, mf);
> }
> 
>-- 
>1.9.1
>
>_______________________________________________
>dev mailing list
>dev@openvswitch.org
>http://openvswitch.org/mailman/listinfo/dev
Andy Zhou Jan. 28, 2016, 3:16 a.m. UTC | #2
On Wed, Jan 27, 2016 at 5:01 PM, Daniele Di Proietto <diproiettod@vmware.com
> wrote:

> For the series:
>
> Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
>
> I didn't observe any performance regressions.
>
> Thanks!
>

Thanks for the review and testing. Pushed to master.
diff mbox

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index a7e15aa..8d72e27 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -3178,13 +3178,11 @@  dp_netdev_queue_batches(struct dp_packet *pkt,
 {
     struct packet_batch *batch = flow->batch;
 
-    if (OVS_LIKELY(batch)) {
-        packet_batch_update(batch, pkt, mf);
-        return;
+    if (OVS_UNLIKELY(!batch)) {
+        batch = &batches[(*n_batches)++];
+        packet_batch_init(batch, flow);
     }
 
-    batch = &batches[(*n_batches)++];
-    packet_batch_init(batch, flow);
     packet_batch_update(batch, pkt, mf);
 }