Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH] dax: use switch statement over chained ifs
@ 2023-01-17  2:11 Amy Parker
  2023-01-17  2:41 ` Matthew Wilcox
  2023-01-17 15:52 ` David Laight
  0 siblings, 2 replies; 5+ messages in thread
From: Amy Parker @ 2023-01-17  2:11 UTC (permalink / raw)
  To: willy; +Cc: linux-fsdevel, linux-kernel

This patch uses a switch statement for pe_order, which improves
readability and on some platforms may minorly improve performance. It
also, to improve readability, recognizes that `PAGE_SHIFT - PAGE_SHIFT' is
a constant, and uses 0 in its place instead.

Signed-off-by: Amy Parker <apark0006@student.cerritos.edu>
---
 fs/dax.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index c48a3a93ab29..e8beed601384 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -32,13 +32,16 @@

 static inline unsigned int pe_order(enum page_entry_size pe_size)
 {
-    if (pe_size == PE_SIZE_PTE)
-        return PAGE_SHIFT - PAGE_SHIFT;
-    if (pe_size == PE_SIZE_PMD)
+    switch (pe_size) {
+    case PE_SIZE_PTE:
+        return 0;
+    case PE_SIZE_PMD:
         return PMD_SHIFT - PAGE_SHIFT;
-    if (pe_size == PE_SIZE_PUD)
+    case PE_SIZE_PUD:
         return PUD_SHIFT - PAGE_SHIFT;
-    return ~0;
+    default:
+        return ~0;
+    }
 }

 /* We choose 4096 entries - same as per-zone page wait tables */
-- 
2.39.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-17 15:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-17  2:11 [PATCH] dax: use switch statement over chained ifs Amy Parker
2023-01-17  2:41 ` Matthew Wilcox
2023-01-17  5:07   ` Amy Parker
2023-01-17 14:23     ` Matthew Wilcox
2023-01-17 15:52 ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox