From 023105929064820e58a50242aeaa16845ce9988b Mon Sep 17 00:00:00 2001 From: Antonio Borondo Date: Wed, 3 Oct 2018 11:13:35 +0100 Subject: [PATCH] Fix warning --- .../nlohmann/detail/input/input_adapters.hpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index c2a20ab7d..40560ca16 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -126,14 +126,7 @@ class wide_string_input_adapter : public input_adapter_protocol // check if buffer needs to be filled if (utf8_bytes_index == utf8_bytes_filled) { - if (sizeof(typename WideStringType::value_type) == 2) - { - fill_buffer_utf16(); - } - else - { - fill_buffer_utf32(); - } + fill_buffer(sizeof(typename WideStringType::value_type)); assert(utf8_bytes_filled > 0); assert(utf8_bytes_index == 0); @@ -146,6 +139,18 @@ class wide_string_input_adapter : public input_adapter_protocol } private: + void fill_buffer(size_t size) + { + if (2 == size) + { + fill_buffer_utf16(); + } + else + { + fill_buffer_utf32(); + } + } + void fill_buffer_utf16() { utf8_bytes_index = 0;