linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Subject: [PATCH 2/2] trace-cmd: Optimize check_file_exists()
Date: Mon, 13 Apr 2020 21:44:05 -0400	[thread overview]
Message-ID: <20200414014611.295310002@goodmis.org> (raw)
In-Reply-To: 20200414014403.968063641@goodmis.org

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

       if (dir && !S_ISDIR(st.st_mode))
               return false;
       if (!dir && S_ISDIR(st.st_mode))
               return false;
       return true;

Is the same as:

       return !dir == !S_ISDIR(st.st_mode);

Micro-optimize the logic!

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/tracefs/tracefs-instance.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/lib/tracefs/tracefs-instance.c b/lib/tracefs/tracefs-instance.c
index a8729406b9fc..012a867038b7 100644
--- a/lib/tracefs/tracefs-instance.c
+++ b/lib/tracefs/tracefs-instance.c
@@ -263,12 +263,7 @@ static bool check_file_exists(struct tracefs_instance *instance,
 	if (ret < 0)
 		return false;
 
-	if (dir && !S_ISDIR(st.st_mode))
-		return false;
-	if (!dir && S_ISDIR(st.st_mode))
-		return false;
-
-	return true;
+	return !dir == !S_ISDIR(st.st_mode);
 }
 
 /**
-- 
2.25.1



  parent reply	other threads:[~2020-04-14  1:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14  1:44 [PATCH 0/2] trace-cmd: Some more minor updates Steven Rostedt
2020-04-14  1:44 ` [PATCH 1/2] trace-cmd: Use "exists" instead of "exist" Steven Rostedt
2020-04-14  1:44 ` Steven Rostedt [this message]
2020-04-14 14:16 ` [PATCH 0/2] trace-cmd: Some more minor updates Tzvetomir Stoyanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200414014611.295310002@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).