Skip to content

Commit 33f1a0b

Browse files
committed
Don't use else after throw
1 parent f12748f commit 33f1a0b

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

tinyexpr.cpp

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -516,11 +516,11 @@ namespace te_builtins
516516
{
517517
throw std::runtime_error("Bitwise RIGHT ROTATE operation must use integers.");
518518
}
519-
else if (val1 < 0)
519+
if (val1 < 0)
520520
{
521521
throw std::runtime_error("Bitwise RIGHT ROTATE value must be positive.");
522522
}
523-
else if (val2 > 8)
523+
if (val2 > 8)
524524
{
525525
throw std::runtime_error("Rotation operation must be between 0-8.");
526526
}
@@ -536,11 +536,11 @@ namespace te_builtins
536536
{
537537
throw std::runtime_error("Bitwise LEFT ROTATE operation must use integers.");
538538
}
539-
else if (val1 < 0)
539+
if (val1 < 0)
540540
{
541541
throw std::runtime_error("Bitwise LEFT ROTATE value must be positive.");
542542
}
543-
else if (val2 > 8)
543+
if (val2 > 8)
544544
{
545545
throw std::runtime_error("Rotation operation must be between 0-8.");
546546
}
@@ -556,11 +556,11 @@ namespace te_builtins
556556
{
557557
throw std::runtime_error("Bitwise RIGHT ROTATE operation must use integers.");
558558
}
559-
else if (val1 < 0)
559+
if (val1 < 0)
560560
{
561561
throw std::runtime_error("Bitwise RIGHT ROTATE value must be positive.");
562562
}
563-
else if (val2 > 16)
563+
if (val2 > 16)
564564
{
565565
throw std::runtime_error("Rotation operation must be between 0-16.");
566566
}
@@ -576,11 +576,11 @@ namespace te_builtins
576576
{
577577
throw std::runtime_error("Bitwise LEFT ROTATE operation must use integers.");
578578
}
579-
else if (val1 < 0)
579+
if (val1 < 0)
580580
{
581581
throw std::runtime_error("Bitwise LEFT ROTATE value must be positive.");
582582
}
583-
else if (val2 > 16)
583+
if (val2 > 16)
584584
{
585585
throw std::runtime_error("Rotation operation must be between 0-16.");
586586
}
@@ -600,11 +600,11 @@ namespace te_builtins
600600
{
601601
throw std::runtime_error("Bitwise RIGHT ROTATE operation must use integers.");
602602
}
603-
else if (val1 < 0)
603+
if (val1 < 0)
604604
{
605605
throw std::runtime_error("Bitwise RIGHT ROTATE value must be positive.");
606606
}
607-
else if (val2 > 32)
607+
if (val2 > 32)
608608
{
609609
throw std::runtime_error("Rotation operation must be between 0-32.");
610610
}
@@ -624,11 +624,11 @@ namespace te_builtins
624624
{
625625
throw std::runtime_error("Bitwise LEFT ROTATE operation must use integers.");
626626
}
627-
else if (val1 < 0)
627+
if (val1 < 0)
628628
{
629629
throw std::runtime_error("Bitwise LEFT ROTATE value must be positive.");
630630
}
631-
else if (val2 > 32)
631+
if (val2 > 32)
632632
{
633633
throw std::runtime_error("Rotation operation must be between 0-32.");
634634
}
@@ -648,11 +648,11 @@ namespace te_builtins
648648
{
649649
throw std::runtime_error("Bitwise RIGHT ROTATE operation must use integers.");
650650
}
651-
else if (val1 < 0)
651+
if (val1 < 0)
652652
{
653653
throw std::runtime_error("Bitwise RIGHT ROTATE value must be positive.");
654654
}
655-
else if (val2 > 63)
655+
if (val2 > 63)
656656
{
657657
throw std::runtime_error("Rotation operation must be between 0-63");
658658
}
@@ -672,11 +672,11 @@ namespace te_builtins
672672
{
673673
throw std::runtime_error("Bitwise LEFT ROTATE operation must use integers.");
674674
}
675-
else if (val1 < 0)
675+
if (val1 < 0)
676676
{
677677
throw std::runtime_error("Bitwise LEFT ROTATE value must be positive.");
678678
}
679-
else if (val2 > 63)
679+
if (val2 > 63)
680680
{
681681
throw std::runtime_error("Rotation operation must be between 0-63");
682682
}
@@ -728,11 +728,11 @@ namespace te_builtins
728728
{
729729
throw std::runtime_error("Bitwise NOT must use integers.");
730730
}
731-
else if (val < 0)
731+
if (val < 0)
732732
{
733733
throw std::runtime_error("Bitwise NOT value must be positive.");
734734
}
735-
else if (val > std::numeric_limits<uint8_t>::max())
735+
if (val > std::numeric_limits<uint8_t>::max())
736736
{
737737
throw std::runtime_error("Value is too large for bitwise NOT.");
738738
}
@@ -751,11 +751,11 @@ namespace te_builtins
751751
{
752752
throw std::runtime_error("Bitwise NOT must use integers.");
753753
}
754-
else if (val < 0)
754+
if (val < 0)
755755
{
756756
throw std::runtime_error("Bitwise NOT value must be positive.");
757757
}
758-
else if (val > std::numeric_limits<uint16_t>::max())
758+
if (val > std::numeric_limits<uint16_t>::max())
759759
{
760760
throw std::runtime_error("Value is too large for bitwise NOT.");
761761
}
@@ -777,11 +777,11 @@ namespace te_builtins
777777
{
778778
throw std::runtime_error("Bitwise NOT must use integers.");
779779
}
780-
else if (val < 0)
780+
if (val < 0)
781781
{
782782
throw std::runtime_error("Bitwise NOT value must be positive.");
783783
}
784-
else if (val > std::numeric_limits<uint32_t>::max())
784+
if (val > std::numeric_limits<uint32_t>::max())
785785
{
786786
throw std::runtime_error("Value is too large for bitwise NOT.");
787787
}
@@ -803,11 +803,11 @@ namespace te_builtins
803803
{
804804
throw std::runtime_error("Bitwise NOT must use integers.");
805805
}
806-
else if (val < 0)
806+
if (val < 0)
807807
{
808808
throw std::runtime_error("Bitwise NOT value must be positive.");
809809
}
810-
else if (val > std::numeric_limits<uint64_t>::max())
810+
if (val > std::numeric_limits<uint64_t>::max())
811811
{
812812
throw std::runtime_error("Value is too large for bitwise NOT.");
813813
}
@@ -845,11 +845,11 @@ namespace te_builtins
845845
}
846846
// negative technically should be allowed, but spreadsheet programs do
847847
// not allow them; hence, we won't either
848-
else if (val1 < 0 || val2 < 0)
848+
if (val1 < 0 || val2 < 0)
849849
{
850850
throw std::runtime_error("Bitwise OR operation must use positive integers.");
851851
}
852-
else if (val1 > te_parser::MAX_BITOPS_VAL || val2 > te_parser::MAX_BITOPS_VAL)
852+
if (val1 > te_parser::MAX_BITOPS_VAL || val2 > te_parser::MAX_BITOPS_VAL)
853853
{
854854
throw std::runtime_error("Value is too large for bitwise operation.");
855855
}
@@ -866,11 +866,11 @@ namespace te_builtins
866866
}
867867
// negative technically should be allowed, but spreadsheet programs do
868868
// not allow them; hence, we won't either
869-
else if (val1 < 0 || val2 < 0)
869+
if (val1 < 0 || val2 < 0)
870870
{
871871
throw std::runtime_error("Bitwise XOR operation must use positive integers.");
872872
}
873-
else if (val1 > te_parser::MAX_BITOPS_VAL || val2 > te_parser::MAX_BITOPS_VAL)
873+
if (val1 > te_parser::MAX_BITOPS_VAL || val2 > te_parser::MAX_BITOPS_VAL)
874874
{
875875
throw std::runtime_error("Value is too large for bitwise operation.");
876876
}
@@ -887,11 +887,11 @@ namespace te_builtins
887887
}
888888
// negative technically should be allowed, but spreadsheet programs do
889889
// not allow them; hence, we won't either
890-
else if (val1 < 0 || val2 < 0)
890+
if (val1 < 0 || val2 < 0)
891891
{
892892
throw std::runtime_error("Bitwise AND operation must use positive integers.");
893893
}
894-
else if (val1 > te_parser::MAX_BITOPS_VAL || val2 > te_parser::MAX_BITOPS_VAL)
894+
if (val1 > te_parser::MAX_BITOPS_VAL || val2 > te_parser::MAX_BITOPS_VAL)
895895
{
896896
throw std::runtime_error("Value is too large for bitwise operation.");
897897
}
@@ -912,22 +912,22 @@ namespace te_builtins
912912
{
913913
throw std::runtime_error("Left side of left shift (<<) operation must be an integer.");
914914
}
915-
else if (std::floor(val2) != val2)
915+
if (std::floor(val2) != val2)
916916
{
917917
throw std::runtime_error(
918918
"Additive expression of left shift (<<) operation must be an integer.");
919919
}
920-
else if (val1 < 0)
920+
if (val1 < 0)
921921
{
922922
throw std::runtime_error("Left side of left shift (<<) operation cannot be negative.");
923923
}
924-
else if (val1 > te_parser::MAX_BITOPS_VAL)
924+
if (val1 > te_parser::MAX_BITOPS_VAL)
925925
{
926926
throw std::runtime_error("Value is too large for bitwise operation.");
927927
}
928928
// bitness is limited to 53-bit or 64-bit, so ensure shift doesn't go beyond that
929929
// and cause undefined behavior
930-
else if (val2 < 0 || val2 > MAX_BITNESS_PARAM)
930+
if (val2 < 0 || val2 > MAX_BITNESS_PARAM)
931931
{
932932
throw std::runtime_error(
933933
"Additive expression of left shift (<<) operation must be between 0-" +
@@ -956,20 +956,20 @@ namespace te_builtins
956956
{
957957
throw std::runtime_error("Left side of right shift (>>) operation must be an integer.");
958958
}
959-
else if (std::floor(val2) != val2)
959+
if (std::floor(val2) != val2)
960960
{
961961
throw std::runtime_error(
962962
"Additive expression of right shift (>>) operation must be an integer.");
963963
}
964-
else if (val1 < 0)
964+
if (val1 < 0)
965965
{
966966
throw std::runtime_error("Left side of right shift (<<) operation cannot be negative.");
967967
}
968-
else if (val1 > te_parser::MAX_BITOPS_VAL)
968+
if (val1 > te_parser::MAX_BITOPS_VAL)
969969
{
970970
throw std::runtime_error("Value is too large for bitwise operation.");
971971
}
972-
else if (val2 < 0 || val2 > MAX_BITNESS_PARAM)
972+
if (val2 < 0 || val2 > MAX_BITNESS_PARAM)
973973
{
974974
throw std::runtime_error(
975975
"Additive expression of right shift (>>) operation must be between 0-" +

0 commit comments

Comments
 (0)