Message ID | 20110201195619.GK30899@tyan-ft48-01.lab.bos.redhat.com |
---|---|
State | New |
Headers | show |
Jakub Jelinek <jakub@redhat.com> writes: > Alternatively just fix up ASM_OUTPUT_ASCII in sysv4.h. > for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ > continue; \ > inner loop clearly results in O(n^2) time complexity, completely > unnecessarily. Something like (completely untested) following could fix > it, i.e. only recompute p if it will be different from last iteration. Thanks, but the generic version in elfos.h proved to just work, so there's no need for a almost-duplicate, especially since those tend to be forgotten if the original is modified/optimized/whatever. Since i386-pc-solaris2.9 testing finished successfully, I've now checked in the patch to just remove the i386/sysv4.h version of the macro. Rainer
--- gcc/config/i386/sysv4.h 2010-06-11 11:05:31.766533869 +0200 +++ gcc/config/i386/sysv4.h 2011-02-01 20:53:47.116795897 +0100 @@ -54,16 +54,17 @@ along with GCC; see the file COPYING3. (const unsigned char *) (STR); \ const unsigned char *limit = _ascii_bytes + (LENGTH); \ unsigned bytes_in_chunk = 0; \ + const unsigned char *p = _ascii_bytes; \ for (; _ascii_bytes < limit; _ascii_bytes++) \ { \ - const unsigned char *p; \ if (bytes_in_chunk >= 64) \ { \ fputc ('\n', (FILE)); \ bytes_in_chunk = 0; \ } \ - for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ - continue; \ + if (p <= _ascii_bytes) \ + for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ + continue; \ if (p < limit && (p - _ascii_bytes) <= (long) STRING_LIMIT) \ { \ if (bytes_in_chunk > 0) \