Skip to contentSkip to conversation

master - cleanup: change check order in condition in _check_pv_list fn

PATCH Peter Rajnoha 1 participant 1 message Feb 27, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=379fb90b05b9fae0559fb697981198d8bb58e0f9
Commit:        379fb90b05b9fae0559fb697981198d8bb58e0f9
Parent:        ee4cd2c73774feeef3794c24865add1c28adb946
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Fri Feb 27 14:52:31 2015 +0100
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Fri Feb 27 14:52:38 2015 +0100

cleanup: change check order in condition in _check_pv_list fn

"!dev_cache_get(argv[i], cmd->full_filter) && !rescan_done" --> "!rescan_done && !dev_cache_get(argv[i], cmd->full_filter)

Check the simple condition first (variable), then the function return value (which in this case certainly takes more time to evaluate) - save some time.

---
 tools/reporter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/reporter.c +1 -1
index 0e563ac..9bf366e 100644
@@ -578,7 +578,7 @@ static void _check_pv_list(struct cmd_context *cmd, int argc, char **argv,
 
 	if (args_are_pvs && argc) {
 		for (i = 0; i < argc; i++) {
-			if (!dev_cache_get(argv[i], cmd->full_filter) && !rescan_done) {
+			if (!rescan_done && !dev_cache_get(argv[i], cmd->full_filter)) {
 				cmd->filter->wipe(cmd->filter);
 				/* FIXME scan only one device */
 				lvmcache_label_scan(cmd, 0);