aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2019-04-07 11:43:17 -0700
committerPaul Eggert2019-04-07 11:44:04 -0700
commit404a5470cf1b1ae5bd464aaf8fe909b86faa2e61 (patch)
tree3808ac97bf29c76b275e0fdf55f0fde85468182b /src
parent74732c541228ebb9f0a15b0a22132a85b32de89b (diff)
downloademacs-404a5470cf1b1ae5bd464aaf8fe909b86faa2e61.tar.gz
emacs-404a5470cf1b1ae5bd464aaf8fe909b86faa2e61.zip
Simplify fill_gstring_header
* src/composite.c (fill_gstring_header): Omit first argument HEADER, since in practice it is always nil. Change caller to match. Help the compiler by telling it LEN is nonnegative. Problem found with --enable-gcc-warnings and gcc -O2 -Og.
Diffstat (limited to 'src')
-rw-r--r--src/composite.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/composite.c b/src/composite.c
index c426cbb1246..88f1235f116 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -787,28 +787,19 @@ static Lisp_Object gstring_work;
787static Lisp_Object gstring_work_headers; 787static Lisp_Object gstring_work_headers;
788 788
789static Lisp_Object 789static Lisp_Object
790fill_gstring_header (Lisp_Object header, ptrdiff_t from, ptrdiff_t from_byte, 790fill_gstring_header (ptrdiff_t from, ptrdiff_t from_byte,
791 ptrdiff_t to, Lisp_Object font_object, Lisp_Object string) 791 ptrdiff_t to, Lisp_Object font_object, Lisp_Object string)
792{ 792{
793 ptrdiff_t len = to - from, i; 793 ptrdiff_t len = to - from;
794
795 if (len == 0) 794 if (len == 0)
796 error ("Attempt to shape zero-length text"); 795 error ("Attempt to shape zero-length text");
797 if (VECTORP (header)) 796 eassume (0 < len);
798 { 797 Lisp_Object header = (len <= 8
799 if (ASIZE (header) != len + 1) 798 ? AREF (gstring_work_headers, len - 1)
800 args_out_of_range (header, make_fixnum (len + 1)); 799 : make_uninit_vector (len + 1));
801 }
802 else
803 {
804 if (len <= 8)
805 header = AREF (gstring_work_headers, len - 1);
806 else
807 header = make_uninit_vector (len + 1);
808 }
809 800
810 ASET (header, 0, font_object); 801 ASET (header, 0, font_object);
811 for (i = 0; i < len; i++) 802 for (ptrdiff_t i = 0; i < len; i++)
812 { 803 {
813 int c; 804 int c;
814 805
@@ -1748,7 +1739,7 @@ should be ignored. */)
1748 frombyte = string_char_to_byte (string, frompos); 1739 frombyte = string_char_to_byte (string, frompos);
1749 } 1740 }
1750 1741
1751 header = fill_gstring_header (Qnil, frompos, frombyte, 1742 header = fill_gstring_header (frompos, frombyte,
1752 topos, font_object, string); 1743 topos, font_object, string);
1753 gstring = gstring_lookup_cache (header); 1744 gstring = gstring_lookup_cache (header);
1754 if (! NILP (gstring)) 1745 if (! NILP (gstring))