- Notifications
You must be signed in to change notification settings - Fork28
Commitd303122
committed
Clean up the Simple-8b encoder code.
Coverity complained that simple8b_encode() might read beyond the end ofthe 'diffs' array, in the loop to encode the integers. That was a falsepositive, because we never get into the loop in modes 0 or 1, and thearray is large enough for all the other modes. But I admit it's verysubtle, so it's not surprising that Coverity didn't see it, and it's notvery obvious to humans either. Refactor it, so that the second loopre-computes the differences, instead of carrying them over from the firstloop in the 'diffs' array. This way, the 'diffs' array is not neededanymore. It makes no measurable difference in performance, and seems morestraightforward this way.Also, improve the comments in simple8b_encode(): fix the comment about itsreturn value that was flat-out wrong, and explain the condition when itreturns EMPTY_CODEWORD better.In the passing, move the 'selector' from the codeword's low bits to thehigh bits. It doesn't matter much, but looking at the original paper, andgoogling around for other Simple-8b implementations, that's how it'susually done.Per Coverity, and Tom Lane's report off-list.1 parent148cf5f commitd303122
File tree
2 files changed
+41
-28
lines changed- src
- backend/lib
- test/modules/test_integerset
2 files changed
+41
-28
lines changedLines changed: 30 additions & 22 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
773 | 773 |
| |
774 | 774 |
| |
775 | 775 |
| |
776 |
| - | |
| 776 | + | |
777 | 777 |
| |
778 | 778 |
| |
779 | 779 |
| |
| |||
783 | 783 |
| |
784 | 784 |
| |
785 | 785 |
| |
786 |
| - | |
| 786 | + | |
787 | 787 |
| |
788 |
| - | |
789 |
| - | |
790 |
| - | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
791 | 791 |
| |
792 | 792 |
| |
793 | 793 |
| |
| |||
835 | 835 |
| |
836 | 836 |
| |
837 | 837 |
| |
| 838 | + | |
838 | 839 |
| |
839 | 840 |
| |
840 | 841 |
| |
841 | 842 |
| |
842 | 843 |
| |
843 | 844 |
| |
844 | 845 |
| |
845 |
| - | |
| 846 | + | |
846 | 847 |
| |
847 | 848 |
| |
848 |
| - | |
| 849 | + | |
849 | 850 |
| |
850 | 851 |
| |
851 | 852 |
| |
852 | 853 |
| |
853 |
| - | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
854 | 860 |
| |
855 | 861 |
| |
856 | 862 |
| |
| |||
861 | 867 |
| |
862 | 868 |
| |
863 | 869 |
| |
864 |
| - | |
865 | 870 |
| |
866 | 871 |
| |
867 | 872 |
| |
| |||
891 | 896 |
| |
892 | 897 |
| |
893 | 898 |
| |
| 899 | + | |
894 | 900 |
| |
895 | 901 |
| |
896 | 902 |
| |
897 | 903 |
| |
898 | 904 |
| |
899 |
| - | |
900 |
| - | |
901 | 905 |
| |
902 | 906 |
| |
903 | 907 |
| |
| |||
910 | 914 |
| |
911 | 915 |
| |
912 | 916 |
| |
913 |
| - | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
914 | 924 |
| |
915 | 925 |
| |
916 | 926 |
| |
| |||
924 | 934 |
| |
925 | 935 |
| |
926 | 936 |
| |
927 |
| - | |
| 937 | + | |
928 | 938 |
| |
| 939 | + | |
| 940 | + | |
929 | 941 |
| |
930 |
| - | |
931 | 942 |
| |
| 943 | + | |
| 944 | + | |
932 | 945 |
| |
933 | 946 |
| |
934 | 947 |
| |
935 |
| - | |
936 |
| - | |
| 948 | + | |
937 | 949 |
| |
938 | 950 |
| |
939 | 951 |
| |
| |||
945 | 957 |
| |
946 | 958 |
| |
947 | 959 |
| |
948 |
| - | |
| 960 | + | |
949 | 961 |
| |
950 | 962 |
| |
951 | 963 |
| |
| |||
954 | 966 |
| |
955 | 967 |
| |
956 | 968 |
| |
957 |
| - | |
958 |
| - | |
959 | 969 |
| |
960 | 970 |
| |
961 | 971 |
| |
| |||
976 | 986 |
| |
977 | 987 |
| |
978 | 988 |
| |
979 |
| - | |
| 989 | + | |
980 | 990 |
| |
981 | 991 |
| |
982 | 992 |
| |
983 | 993 |
| |
984 | 994 |
| |
985 | 995 |
| |
986 |
| - | |
987 |
| - | |
988 | 996 |
| |
989 | 997 |
| |
990 | 998 |
| |
|
Lines changed: 11 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
539 | 539 |
| |
540 | 540 |
| |
541 | 541 |
| |
| 542 | + | |
542 | 543 |
| |
543 | 544 |
| |
544 | 545 |
| |
| |||
563 | 564 |
| |
564 | 565 |
| |
565 | 566 |
| |
566 |
| - | |
| 567 | + | |
567 | 568 |
| |
568 | 569 |
| |
569 |
| - | |
| 570 | + | |
| 571 | + | |
570 | 572 |
| |
571 |
| - | |
| 573 | + | |
| 574 | + | |
572 | 575 |
| |
573 | 576 |
| |
574 |
| - | |
575 |
| - | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
576 | 580 |
| |
577 | 581 |
| |
578 | 582 |
| |
579 | 583 |
| |
580 | 584 |
| |
581 | 585 |
| |
582 | 586 |
| |
583 |
| - | |
| 587 | + | |
| 588 | + | |
584 | 589 |
| |
585 | 590 |
| |
586 | 591 |
| |
|
0 commit comments
Comments
(0)