diff mbox series

[2/2] trace-cmd: Optimize check_file_exists()

Message ID 20200414014611.295310002@goodmis.org (mailing list archive)
State Superseded
Headers show
Series None | expand

Commit Message

Steven Rostedt April 14, 2020, 1:44 a.m. UTC
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 mbox series

Patch

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);
 }
 
 /**