Patchwork [net-next] net: replace continue with break to reduce unnecessary loop in xxx_xmarksources

login
register
mail settings
Submitter roy.qing.li@gmail.com
Date April 5, 2012, 9:36 a.m.
Message ID <1333618589-13839-1-git-send-email-roy.qing.li@gmail.com>
Download mbox | patch
Permalink /patch/150898/
State Accepted
Delegated to: David Miller
Headers show

Comments

roy.qing.li@gmail.com - April 5, 2012, 9:36 a.m.
From: RongQing.Li <roy.qing.li@gmail.com>

The conditional which decides to skip inactive filters does not
change with the change of loop index, so it is unnecessary to
check them many times.

Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
---
 net/ipv4/igmp.c  |    2 +-
 net/ipv6/mcast.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
David Miller - April 5, 2012, 9:43 a.m.
From: roy.qing.li@gmail.com
Date: Thu,  5 Apr 2012 17:36:29 +0800

> From: RongQing.Li <roy.qing.li@gmail.com>
> 
> The conditional which decides to skip inactive filters does not
> change with the change of loop index, so it is unnecessary to
> check them many times.
> 
> Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 5dfecfd..ceaac24 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -774,7 +774,7 @@  static int igmp_xmarksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs)
 			if (psf->sf_count[MCAST_INCLUDE] ||
 			    pmc->sfcount[MCAST_EXCLUDE] !=
 			    psf->sf_count[MCAST_EXCLUDE])
-				continue;
+				break;
 			if (srcs[i] == psf->sf_inaddr) {
 				scount++;
 				break;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index b2869ca..7dfb89f 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1061,7 +1061,7 @@  static int mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs,
 			if (psf->sf_count[MCAST_INCLUDE] ||
 			    pmc->mca_sfcount[MCAST_EXCLUDE] !=
 			    psf->sf_count[MCAST_EXCLUDE])
-				continue;
+				break;
 			if (ipv6_addr_equal(&srcs[i], &psf->sf_addr)) {
 				scount++;
 				break;