[libcxx-commits] [libcxx] [libc++][chrono] Fixes leap seconds. (PR #90070)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 4 07:39:58 PDT 2024


================
@@ -626,29 +626,49 @@ static void __parse_leap_seconds(vector<leap_second>& __leap_seconds, istream&&
   // seconds since 1 January 1970.
   constexpr auto __offset = sys_days{1970y / January / 1} - sys_days{1900y / January / 1};
 
-  while (true) {
-    switch (__input.peek()) {
-    case istream::traits_type::eof():
-      return;
-
-    case ' ':
-    case '\t':
-    case '\n':
-      __input.get();
-      continue;
+  struct __entry {
+    sys_seconds __timestamp;
+    seconds __value;
+  };
+  vector<__entry> __entries;
+  [&] {
----------------
mordante wrote:

In the `while` loop there is a `switch` that should terminate the processing when `EOF` is found. Since test is in a `switch` I can't use `break`. Using a IILE allows to use `return`. Refactoring this lambda to a function doesn't improve code readability, so I prefer an IILE.

https://github.com/llvm/llvm-project/pull/90070


More information about the libcxx-commits mailing list