From 375b05a17d3bc7c93eee9933748e85fc5420923b Mon Sep 17 00:00:00 2001
From: Niels Lohmann <mail@nlohmann.me>
Date: Sat, 17 Mar 2018 23:31:18 +0100
Subject: [PATCH] :hammer: cleanup

---
 include/nlohmann/detail/input/json_sax.hpp | 26 +++++++++++++---------
 single_include/nlohmann/json.hpp           | 26 +++++++++++++---------
 2 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp
index a0ffdc66..8bbaa9c9 100644
--- a/include/nlohmann/detail/input/json_sax.hpp
+++ b/include/nlohmann/detail/input/json_sax.hpp
@@ -277,17 +277,23 @@ class json_sax_dom_parser : public json_sax<BasicJsonType>
         }
         else
         {
-            assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
-            if (ref_stack.back()->is_array())
+            switch (ref_stack.back()->m_type)
             {
-                ref_stack.back()->m_value.array->push_back(BasicJsonType(std::forward<Value>(v)));
-                return &(ref_stack.back()->m_value.array->back());
-            }
-            else
-            {
-                assert(object_element);
-                *object_element = BasicJsonType(std::forward<Value>(v));
-                return object_element;
+                case value_t::array:
+                {
+                    ref_stack.back()->m_value.array->push_back(BasicJsonType(std::forward<Value>(v)));
+                    return &(ref_stack.back()->m_value.array->back());
+                }
+
+                case value_t::object:
+                {
+                    assert(object_element);
+                    *object_element = BasicJsonType(std::forward<Value>(v));
+                    return object_element;
+                }
+
+                default:
+                    assert(false);  // LCOV_EXCL_LINE
             }
         }
     }
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index 639d6400..50302903 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -3413,17 +3413,23 @@ class json_sax_dom_parser : public json_sax<BasicJsonType>
         }
         else
         {
-            assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
-            if (ref_stack.back()->is_array())
+            switch (ref_stack.back()->m_type)
             {
-                ref_stack.back()->m_value.array->push_back(BasicJsonType(std::forward<Value>(v)));
-                return &(ref_stack.back()->m_value.array->back());
-            }
-            else
-            {
-                assert(object_element);
-                *object_element = BasicJsonType(std::forward<Value>(v));
-                return object_element;
+                case value_t::array:
+                {
+                    ref_stack.back()->m_value.array->push_back(BasicJsonType(std::forward<Value>(v)));
+                    return &(ref_stack.back()->m_value.array->back());
+                }
+
+                case value_t::object:
+                {
+                    assert(object_element);
+                    *object_element = BasicJsonType(std::forward<Value>(v));
+                    return object_element;
+                }
+
+                default:
+                    assert(false);  // LCOV_EXCL_LINE
             }
         }
     }