[libcxx-commits] [libcxx] [libc++][NFC] Rewrite function call on two lines for clarity (PR #79141)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 23 06:22:25 PST 2024


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/79141

Previously, there was a ternary conditional with a less-than comparison appearing inside a template argument, which was really confusing because of the <...> of the function template. This patch rewrites the same statement on two lines for clarity.

>From 4a53384e90e01cd2b9b499d6df7ba4148edadafe Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 23 Jan 2024 09:19:18 -0500
Subject: [PATCH] [libc++][NFC] Rewrite function call on two lines for clarity

Previously, there was a ternary conditional with a less-than comparison
appearing inside a template argument, which was really confusing because
of the <...> of the function template. This patch rewrites the same
statement on two lines for clarity.
---
 libcxx/include/string | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/string b/libcxx/include/string
index e97139206d4fa7c..085178fe1a9ed01 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1948,8 +1948,8 @@ private:
     if (__s < __min_cap) {
       return static_cast<size_type>(__min_cap) - 1;
     }
-    size_type __guess =
-        __align_it < sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1 > (__s + 1) - 1;
+    const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1;
+    size_type __guess          = __align_it<__boundary>(__s + 1) - 1;
     if (__guess == __min_cap)
       ++__guess;
     return __guess;



More information about the libcxx-commits mailing list