1 new commit in XEmacs:
https://bitbucket.org/xemacs/xemacs/commits/7a538e1a4676/
Changeset: 7a538e1a4676
User: kehoea
Date: 2013-12-19 19:13:11
Summary: Use skip_ascii() in no_conversion_convert() when encoding.
src/ChangeLog addition:
2013-12-19 Aidan Kehoe <kehoea(a)parhasard.net>
* text.c:
* text.h:
* text.h (skip_ascii):
Move skip_ascii (), the very fast inline function from the
bytecount-to-charcount code, to text.h, to allow the coding
systems to use it too as needed.
* file-coding.c (no_conversion_convert):
Use skip_ascii() as appropriate here, halving the time taken to
write large files in my tests (again, relevant to VM buffers, but
not a panacea to our issues with them.)
Affected #: 4 files
diff -r 94a6b8fbd56e98dd8d90de2b793cea1c5fd21353 -r
7a538e1a4676a2229b4f1806dfa26725226f0ba7 src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
+2013-12-19 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * text.c:
+ * text.h:
+ * text.h (skip_ascii):
+ Move skip_ascii (), the very fast inline function from the
+ bytecount-to-charcount code, to text.h, to allow the coding
+ systems to use it too as needed.
+ * file-coding.c (no_conversion_convert):
+ Use skip_ascii() as appropriate here, halving the time taken to
+ write large files in my tests (again, relevant to VM buffers, but
+ not a panacea to our issues with them.)
+
2013-12-17 Aidan Kehoe <kehoea(a)parhasard.net>
* lisp.h:
diff -r 94a6b8fbd56e98dd8d90de2b793cea1c5fd21353 -r
7a538e1a4676a2229b4f1806dfa26725226f0ba7 src/file-coding.c
--- a/src/file-coding.c
+++ b/src/file-coding.c
@@ -2851,18 +2851,29 @@
}
else
{
-
- while (n--)
+ const Ibyte *bend = (const Ibyte *)src + n;
+
+ while (n > 0)
{
- c = *src++;
- if (byte_ascii_p (c))
+ if (byte_ascii_p (*src))
{
- assert (ch == 0);
- Dynarr_add (dst, c);
+ const Ibyte *nonascii = skip_ascii ((Ibyte *)src, bend);
+
+ Dynarr_add_many (dst, src, nonascii - src);
+ n -= nonascii - src;
+
+ src = nonascii;
+ if (n < 1)
+ {
+ break;
+ }
}
+
+ n--, c = *src++;
+
#ifdef MULE
- else if (ibyte_leading_byte_p (c))
- {
+ if (ibyte_leading_byte_p (c))
+ {
assert (ch == 0);
if (c == LEADING_BYTE_LATIN_ISO8859_1 ||
c == LEADING_BYTE_CONTROL_1)
diff -r 94a6b8fbd56e98dd8d90de2b793cea1c5fd21353 -r
7a538e1a4676a2229b4f1806dfa26725226f0ba7 src/text.c
--- a/src/text.c
+++ b/src/text.c
@@ -2204,79 +2204,6 @@
#ifdef MULE
-#ifdef EFFICIENT_INT_128_BIT
-# define STRIDE_TYPE INT_128_BIT
-# define HIGH_BIT_MASK \
- MAKE_128_BIT_UNSIGNED_CONSTANT (0x80808080808080808080808080808080)
-#elif defined (EFFICIENT_INT_64_BIT)
-# define STRIDE_TYPE INT_64_BIT
-# define HIGH_BIT_MASK MAKE_64_BIT_UNSIGNED_CONSTANT (0x8080808080808080)
-#else
-# define STRIDE_TYPE INT_32_BIT
-# define HIGH_BIT_MASK MAKE_32_BIT_UNSIGNED_CONSTANT (0x80808080)
-#endif
-
-#define ALIGN_BITS ((EMACS_UINT) (ALIGNOF (STRIDE_TYPE) - 1))
-#define ALIGN_MASK (~ ALIGN_BITS)
-#define ALIGNED(ptr) ((((EMACS_UINT) ptr) & ALIGN_BITS) == 0)
-#define STRIDE sizeof (STRIDE_TYPE)
-
-/* Skip as many ASCII bytes as possible in the memory block [PTR, END).
- Return pointer to the first non-ASCII byte. optimized for long
- stretches of ASCII. */
-inline static const Ibyte *
-skip_ascii (const Ibyte *ptr, const Ibyte *end)
-{
- const unsigned STRIDE_TYPE *ascii_end;
-
- /* Need to do in 3 sections -- before alignment start, aligned chunk,
- after alignment end. */
- while (!ALIGNED (ptr))
- {
- if (ptr == end || !byte_ascii_p (*ptr))
- return ptr;
- ptr++;
- }
- ascii_end = (const unsigned STRIDE_TYPE *) ptr;
- /* This loop screams, because we can detect ASCII
- characters 4 or 8 at a time. */
- while ((const Ibyte *) ascii_end + STRIDE <= end
- && !(*ascii_end & HIGH_BIT_MASK))
- ascii_end++;
- ptr = (Ibyte *) ascii_end;
- while (ptr < end && byte_ascii_p (*ptr))
- ptr++;
- return ptr;
-}
-
-/* Skip as many ASCII bytes as possible in the memory block [END, PTR),
- going downwards. Return pointer to the location above the first
- non-ASCII byte. Optimized for long stretches of ASCII. */
-inline static const Ibyte *
-skip_ascii_down (const Ibyte *ptr, const Ibyte *end)
-{
- const unsigned STRIDE_TYPE *ascii_end;
-
- /* Need to do in 3 sections -- before alignment start, aligned chunk,
- after alignment end. */
- while (!ALIGNED (ptr))
- {
- if (ptr == end || !byte_ascii_p (*(ptr - 1)))
- return ptr;
- ptr--;
- }
- ascii_end = (const unsigned STRIDE_TYPE *) ptr - 1;
- /* This loop screams, because we can detect ASCII
- characters 4 or 8 at a time. */
- while ((const Ibyte *) ascii_end >= end
- && !(*ascii_end & HIGH_BIT_MASK))
- ascii_end--;
- ptr = (Ibyte *) (ascii_end + 1);
- while (ptr > end && byte_ascii_p (*(ptr - 1)))
- ptr--;
- return ptr;
-}
-
/* Function equivalents of bytecount_to_charcount/charcount_to_bytecount.
These work on strings of all sizes but are more efficient than a simple
loop on large strings and probably less efficient on sufficiently small
diff -r 94a6b8fbd56e98dd8d90de2b793cea1c5fd21353 -r
7a538e1a4676a2229b4f1806dfa26725226f0ba7 src/text.h
--- a/src/text.h
+++ b/src/text.h
@@ -831,12 +831,91 @@
}
}
+#ifdef EFFICIENT_INT_128_BIT
+# define STRIDE_TYPE INT_128_BIT
+# define HIGH_BIT_MASK \
+ MAKE_128_BIT_UNSIGNED_CONSTANT (0x80808080808080808080808080808080)
+#elif defined (EFFICIENT_INT_64_BIT)
+# define STRIDE_TYPE INT_64_BIT
+# define HIGH_BIT_MASK MAKE_64_BIT_UNSIGNED_CONSTANT (0x8080808080808080)
+#else
+# define STRIDE_TYPE INT_32_BIT
+# define HIGH_BIT_MASK MAKE_32_BIT_UNSIGNED_CONSTANT (0x80808080)
+#endif
+
+#define ALIGN_BITS ((EMACS_UINT) (ALIGNOF (STRIDE_TYPE) - 1))
+#define ALIGN_MASK (~ ALIGN_BITS)
+#define ALIGNED(ptr) ((((EMACS_UINT) ptr) & ALIGN_BITS) == 0)
+#define STRIDE sizeof (STRIDE_TYPE)
+
+/* Skip as many ASCII bytes as possible in the memory block [PTR, END).
+ Return pointer to the first non-ASCII byte. optimized for long
+ stretches of ASCII. */
+DECLARE_INLINE_HEADER (
+const Ibyte *
+skip_ascii (const Ibyte *ptr, const Ibyte *end)
+)
+{
+ const unsigned STRIDE_TYPE *ascii_end;
+
+ /* Need to do in 3 sections -- before alignment start, aligned chunk,
+ after alignment end. */
+ while (!ALIGNED (ptr))
+ {
+ if (ptr == end || !byte_ascii_p (*ptr))
+ return ptr;
+ ptr++;
+ }
+ ascii_end = (const unsigned STRIDE_TYPE *) ptr;
+ /* This loop screams, because we can detect ASCII
+ characters 4 or 8 at a time. */
+ while ((const Ibyte *) ascii_end + STRIDE <= end
+ && !(*ascii_end & HIGH_BIT_MASK))
+ ascii_end++;
+ ptr = (Ibyte *) ascii_end;
+ while (ptr < end && byte_ascii_p (*ptr))
+ ptr++;
+ return ptr;
+}
+
+/* Skip as many ASCII bytes as possible in the memory block [END, PTR),
+ going downwards. Return pointer to the location above the first
+ non-ASCII byte. Optimized for long stretches of ASCII. */
+DECLARE_INLINE_HEADER (
+const Ibyte *
+skip_ascii_down (const Ibyte *ptr, const Ibyte *end)
+)
+{
+ const unsigned STRIDE_TYPE *ascii_end;
+
+ /* Need to do in 3 sections -- before alignment start, aligned chunk,
+ after alignment end. */
+ while (!ALIGNED (ptr))
+ {
+ if (ptr == end || !byte_ascii_p (*(ptr - 1)))
+ return ptr;
+ ptr--;
+ }
+ ascii_end = (const unsigned STRIDE_TYPE *) ptr - 1;
+ /* This loop screams, because we can detect ASCII
+ characters 4 or 8 at a time. */
+ while ((const Ibyte *) ascii_end >= end
+ && !(*ascii_end & HIGH_BIT_MASK))
+ ascii_end--;
+ ptr = (Ibyte *) (ascii_end + 1);
+ while (ptr > end && byte_ascii_p (*(ptr - 1)))
+ ptr--;
+ return ptr;
+}
+
#else
#define bytecount_to_charcount(ptr, len) ((Charcount) (len))
#define bytecount_to_charcount_fmt(ptr, len, fmt) ((Charcount) (len))
#define charcount_to_bytecount(ptr, len) ((Bytecount) (len))
#define charcount_to_bytecount_fmt(ptr, len, fmt) ((Bytecount) (len))
+#define skip_ascii(ptr, end) end
+#define skip_ascii_down(ptr, end) end
#endif /* MULE */
Repository URL:
https://bitbucket.org/xemacs/xemacs/
--
This is a commit notification from
bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches