zhangqiongyu opened a new pull request, #3075: URL: https://github.com/apache/brpc/pull/3075
### What problem does this PR solve? Issue Number: no Problem Summary: Hello maintainers, This PR makes two contributions: ##### 1. Code Quality Improvement: It replaces the C-style cast in SpanEarlier with static_cast. ##### 2. Discussion on Robustness (Important): During my usage of bRPC, I encountered a scenario where the container being sorted by SpanEarlier contained bvar::Collected* pointers that were not Span instances. This led to a crash due to the unsafe downcast. The current implementation implicitly assumes that only Span objects will ever be passed to this comparator. While this is efficient, it's not robust against incorrect usage. ### What is changed and the side effects? Changed: Using static_cast instead of a C-style cast is a modern C++ best practice. It improves code quality by: Type Safety: It provides compile-time checks for the validity of the cast within the type hierarchy. Clarity: It makes the programmer's intent (a static downcast) explicit. Maintainability: It's easier to search for and audit C++-style casts. This change has no impact on runtime performance or behavior, as it preserves the original assumption that the bvar::Collected* pointers are guaranteed to be Span instances. Side effects: - Performance effects: no - Breaking backward compatibility: no --- ### Check List: - Please make sure your changes are compilable. - When providing us with a new feature, it is best to add related tests. - Please follow [Contributor Covenant Code of Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org