[Top][All Lists]

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

Re: How to quickly compare equality of structs ...

From: Stefan Monnier
Subject: Re: How to quickly compare equality of structs ...
Date: Tue, 07 May 2019 08:41:43 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> If for example, the old cache contains a fake cursor with an x of 0 and
> a y of 3, then the key is 9.  I would search the new tentative cache for
> a key of 9

That's a for-loop over the table with 1 int-comparison per iteration.

> -- if none is found, then this fake cursor must be erased.
> If a key of 9 is found in the new tentative cache, then proceed to do one of
> the methods suggested by Paul -- i.e., "compare each member of the struct"

That's a for-loop over the table with 2 int-comparisons per iteration.

The extra comparison per iteration is likely to be negligible.

> With an arbitrary estimated need of approximately 250 or so fake cursors for
> any live window, a "for" loop to search for a unique key in the new
> tentative cache is probably sufficiently effective.  I was; however, also
> thinking about the possibility of using a key in the context of a hash table
> if that would be more prudent.

I don't know how your fake-cursors are represented in the Elisp world,
but maybe you can add to the structs in the above table a pointer back
to the corresponding Elisp data, and then you can perform a single scan
of the table and for each such cursor, check the Elisp side to see if
it's still "live".  This would avoid the lookup altogether?

I'm probably not making sense, tho, since I have no idea how your
system is structured.  Don't mind me,


reply via email to

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