[libcxx-commits] [libcxx] [libc++] Remove unnecessary static_casts in std::forward_list (PR #130310)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 7 09:29:22 PST 2025
https://github.com/winner245 created https://github.com/llvm/llvm-project/pull/130310
The patch removes unnecessary casts to void* pointers and eliminates an identity cast.
>From 976cc9ef14d98076514f30831fba5b7515491706 Mon Sep 17 00:00:00 2001
From: Peng Liu <winner245 at hotmail.com>
Date: Fri, 7 Mar 2025 12:19:13 -0500
Subject: [PATCH] Remove unnecessary static_casts in std::forward_list
---
libcxx/include/forward_list | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 7582de20995b9..ef18d646440cd 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -296,7 +296,7 @@ struct __forward_node_traits {
# endif
_LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__node_pointer __p) {
- return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__p));
+ return static_cast<__begin_node_pointer>(__p);
}
};
@@ -364,10 +364,10 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_iterator {
__begin_node_pointer __ptr_;
_LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const {
- return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_));
+ return __ptr_;
}
_LIBCPP_HIDE_FROM_ABI __node_pointer __get_unsafe_node_pointer() const {
- return static_cast<__node_pointer>(static_cast<__void_pointer>(__ptr_));
+ return static_cast<__node_pointer>(__ptr_);
}
_LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {}
@@ -428,10 +428,10 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator {
__begin_node_pointer __ptr_;
_LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const {
- return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_));
+ return __ptr_;
}
_LIBCPP_HIDE_FROM_ABI __node_pointer __get_unsafe_node_pointer() const {
- return static_cast<__node_pointer>(static_cast<__void_pointer>(__ptr_));
+ return static_cast<__node_pointer>(__ptr_);
}
_LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {}
More information about the libcxx-commits
mailing list