comparison src/search.c @ 16880:40ea37a6dc40

(skip_chars): Optimize by not calling SET_PT in the loop.
author Richard M. Stallman <rms@gnu.org>
date Sun, 19 Jan 1997 01:28:07 +0000
parents 039ef6e74d3a
children df904355f033
comparison
equal deleted inserted replaced
16879:b020aae1fa01 16880:40ea37a6dc40
728 728
729 while (p != pend) 729 while (p != pend)
730 { 730 {
731 c = *p++; 731 c = *p++;
732 if (syntaxp) 732 if (syntaxp)
733 fastmap[c] = 1; 733 fastmap[syntax_spec_code[c]] = 1;
734 else 734 else
735 { 735 {
736 if (c == '\\') 736 if (c == '\\')
737 { 737 {
738 if (p == pend) break; 738 if (p == pend) break;
752 else 752 else
753 fastmap[c] = 1; 753 fastmap[c] = 1;
754 } 754 }
755 } 755 }
756 756
757 if (syntaxp && fastmap['-'] != 0)
758 fastmap[' '] = 1;
759
760 /* If ^ was the first character, complement the fastmap. */ 757 /* If ^ was the first character, complement the fastmap. */
761 758
762 if (negate) 759 if (negate)
763 for (i = 0; i < sizeof fastmap; i++) 760 for (i = 0; i < sizeof fastmap; i++)
764 fastmap[i] ^= 1; 761 fastmap[i] ^= 1;
765 762
766 { 763 {
767 int start_point = PT; 764 int start_point = PT;
765 int pos = PT;
768 766
769 immediate_quit = 1; 767 immediate_quit = 1;
770 if (syntaxp) 768 if (syntaxp)
771 { 769 {
772
773 if (forwardp) 770 if (forwardp)
774 { 771 {
775 while (PT < XINT (lim) 772 while (pos < XINT (lim)
776 && fastmap[(unsigned char) syntax_code_spec[(int) SYNTAX (FETCH_CHAR (PT))]]) 773 && fastmap[(int) SYNTAX (FETCH_CHAR (pos))])
777 SET_PT (PT + 1); 774 pos++;
778 } 775 }
779 else 776 else
780 { 777 {
781 while (PT > XINT (lim) 778 while (pos > XINT (lim)
782 && fastmap[(unsigned char) syntax_code_spec[(int) SYNTAX (FETCH_CHAR (PT - 1))]]) 779 && fastmap[(int) SYNTAX (FETCH_CHAR (pos - 1))])
783 SET_PT (PT - 1); 780 pos--;
784 } 781 }
785 } 782 }
786 else 783 else
787 { 784 {
788 if (forwardp) 785 if (forwardp)
789 { 786 {
790 while (PT < XINT (lim) && fastmap[FETCH_CHAR (PT)]) 787 while (pos < XINT (lim) && fastmap[FETCH_CHAR (pos)])
791 SET_PT (PT + 1); 788 pos++;
792 } 789 }
793 else 790 else
794 { 791 {
795 while (PT > XINT (lim) && fastmap[FETCH_CHAR (PT - 1)]) 792 while (pos > XINT (lim) && fastmap[FETCH_CHAR (pos - 1)])
796 SET_PT (PT - 1); 793 pos--;
797 } 794 }
798 } 795 }
796 SET_PT (pos);
799 immediate_quit = 0; 797 immediate_quit = 0;
800 798
801 return make_number (PT - start_point); 799 return make_number (PT - start_point);
802 } 800 }
803 } 801 }