[llvm-branch-commits] [libcxx] [libc++][chrono] Completes the tzdb class. (PR #82157)
Louis Dionne via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Mar 5 09:47:54 PST 2024
================
@@ -43,6 +44,40 @@ struct tzdb {
vector<time_zone_link> links;
vector<leap_second> leap_seconds;
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* __locate_zone(string_view __name) const {
+ if (const time_zone* __result = __find_in_zone(__name); __result)
+ return __result;
+
+ if (auto __it = ranges::lower_bound(links, __name, {}, &time_zone_link::name);
+ __it != links.end() && __it->name() == __name)
+ if (const time_zone* __result = __find_in_zone(__it->target()); __result)
----------------
ldionne wrote:
It would be interesting to have a test that we don't follow links transitively. This can be done by creating a tzdb that contains a link to a link, and testing that `locate_zone` doesn't find it. And if you changed the code to actually try to be "clever" and follow links transitively, the test would suddenly pass (well, fail but you get the point).
https://github.com/llvm/llvm-project/pull/82157
More information about the llvm-branch-commits
mailing list