emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compiling Elisp to a native code with a GCC plugin


From: David Kastrup
Subject: Re: Compiling Elisp to a native code with a GCC plugin
Date: Fri, 17 Sep 2010 15:31:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Lars Magne Ingebrigtsen <address@hidden> writes:

> "Stephen J. Turnbull" <address@hidden> writes:
>
>>  > Does everything have to be slow?  :-)
>>
>> Wrong polarity.  The question here is "does everything have to be
>> fast?", and the answer is "no -- I mean, HELL NO!"
>>
>> Make your case that this function needs to be faster than a pure elisp
>> implementation.
>
> I think that's a rather ... stunning approach, but might explain many
> things about XEmacs.
>
> I've presented a use case, and I've demonstrated how all the alternative
> implementations are 50-150% slower than my suggested new implementation,
> and I've done the implementation, which turned out to be totally
> trivial.

Not really sure about that.

+ looking_at_literally (Lisp_Object string)
+ {
+   int start_byte = CHAR_TO_BYTE (PT);
+   int end_byte, end = PT + SCHARS (string);

PT + SCHARS (string) can overflow here.  Better check first rather than
later whether ZV - PT < SCHARS (string).

Yes, I know that most-positive-fixnum <= MAX_INT/2, but just on
principle.

+   end_byte = CHAR_TO_BYTE (end);
+ 
+   if (! memcmp (SDATA (string), BYTE_POS_ADDR (start_byte),
+               end_byte - start_byte))

That is assuming that both string and buffer are identically encoded
(nowadays that likely means both have the same multibyteness).

-- 
David Kastrup




reply via email to

[Prev in Thread] Current Thread [Next in Thread]