Skip to content

Commit 53cd438

Browse files
committed
Removed old bigint::parse
1 parent a181387 commit 53cd438

File tree

1 file changed

+0
-82
lines changed

1 file changed

+0
-82
lines changed

include/jsoncons/utility/bigint.hpp

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -743,88 +743,6 @@ class basic_bigint
743743
}
744744
}
745745

746-
template <typename CharT>
747-
static utility::to_number_result<CharT> parse(const CharT* data, size_type length,
748-
basic_bigint<Allocator>& value, const Allocator& alloc = Allocator())
749-
{
750-
if (JSONCONS_UNLIKELY(length == 0))
751-
{
752-
return utility::to_number_result<CharT>(data, std::errc::invalid_argument);
753-
}
754-
755-
if (*data == '-')
756-
{
757-
return parse(data+1, length-1, true, value, alloc);
758-
}
759-
else
760-
{
761-
return parse(data, length, false, value, alloc);
762-
}
763-
}
764-
765-
template <typename CharT>
766-
static utility::to_number_result<CharT> parse(const CharT* data, size_type length,
767-
bool neg, basic_bigint<Allocator>& value, const Allocator& alloc = Allocator())
768-
{
769-
if (JSONCONS_UNLIKELY(length == 0))
770-
{
771-
return utility::to_number_result<CharT>(data, std::errc::invalid_argument);
772-
}
773-
774-
const CharT* last = data + length;
775-
const CharT* p = data;
776-
777-
while (p < last && *p == '0')
778-
{
779-
++p;
780-
}
781-
if (p == last)
782-
{
783-
value = std::move(basic_bigint{0, alloc});
784-
return utility::to_number_result<CharT>(last, std::errc{});
785-
}
786-
size_type num_digits = last - data;
787-
size_type num_words;
788-
if (length < 10)
789-
{
790-
num_words = 1;
791-
}
792-
else
793-
{
794-
size_type num_bits = (size_type)(((num_digits*detail::bits_per_digit[10]) >> 10) + 1);
795-
num_words = (num_bits+63) >> 6;
796-
}
797-
798-
basic_bigint<Allocator> v(0, alloc);
799-
v.reserve(num_words);
800-
for (size_type i = 0; i < length; i++)
801-
{
802-
CharT c = data[i];
803-
switch (c)
804-
{
805-
case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9':
806-
v = (v * 10u) + (word_type)(c - '0');
807-
break;
808-
default:
809-
return utility::to_number_result<CharT>(data+i, std::errc::invalid_argument);
810-
}
811-
}
812-
813-
//auto view = v.get_storage_view();
814-
//if (num_words != view.size())
815-
//{
816-
// std::cout << "Unexpected num_words! num_words: " << num_words << ", " << num_words << ", size: " << view.size() << "\n";
817-
//}
818-
819-
if (neg)
820-
{
821-
v.set_negative(true);
822-
}
823-
824-
value = std::move(v);
825-
return utility::to_number_result<CharT>(last, std::errc{});
826-
}
827-
828746
template <typename CharT>
829747
static basic_bigint<Allocator> parse_radix(const CharT* data, size_type length, uint8_t radix)
830748
{

0 commit comments

Comments
 (0)