emacs-devel
[Top][All Lists]
Advanced

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

Re: Simple optimization for read_avail_input()


From: Kim F. Storm
Subject: Re: Simple optimization for read_avail_input()
Date: 03 Feb 2004 15:17:38 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Dmitry Antipov <address@hidden> writes:

> Hello,
> 
> It's clear here that very simple function read_avail_input() wastes a lot of
> CPU time. IMHO this is because it wants to zero large 'struct input_event buf'
> (which is KBD_BUFFER_SIZE (4096, except old MacOSs) * sizeof (struct 
> input_event)
> (44 bytes on 32-bit systems)) every time. But we can clear all 'buf' only once
> and clear only used slots next time. The following patch illustrates this 
> idea:

Nice idea, but in its current form it fails because the buf array is allocated 
on 
the stack.  It may work to just declare it static though.

> 
> What do you think about this idea ?

I think it's ok, if we can guarantee that read_avail_input is never called
recursively  (I haven't checked).

But I really wonder why it is necessary to initialize the array at all.

It would seem more sensible simply to require that the functions which
stuff things into an input_event do the EVENT_INIT themselves -- if
necessary.  Of course, it is more work to find these places, but it
seems more correct to do it that way.

BTW, it definitely is unnecessary to init the whole array if
read_socket_hook is NULL; we could just init the first nread
elements in that case.

-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

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