Re: Speedup canvas itemconfigure -fill for many polygons.



On 31 Mar, 10:34, Alexandre Ferrieux <alexandre.ferri...@xxxxxxxxx>
wrote:
On Mar 31, 8:31 am, Mats <mats...@xxxxxxxxx> wrote:



On 31 Mar, 00:41, Alexandre Ferrieux <alexandre.ferri...@xxxxxxxxx>
wrote:
Best would be to rewrite the canvas tag code to use hash tables
instead but
I haven't done that (yet) in tkp::canvas.

By the way Mats, what's the plan regarding tkp ? Is the goal to keep
compatibility with vanilla canvas, and then to merge, or is it forking
just like Ttk lives side-by-side with legacy Tk widgets ?

It is already 100% compatible with standard canvas since I've taken
over its
code, and had to do a lot of rewriting, mainly due to the swtch to the
object based option parsing. My only plan is to make tkp::canvas
compatible
with ordinary canvas, and add as much as possible to make it very easy
to use SVG-like drawings. Another design feature is to keep separate
the
actual new drawing model from the canvas code so it can be used for
other tasks as well.
This work is currently delayed due to the 8.5 upgrade of my coccinella
code.


Any ideas of how that code should work?

Curious you ask that, you're the expert :-)
To do this I'd just add proper housekeeping code to keep the hashtable
in sync with added/removed tags and items, just like any inverse
function implementation. Now how hard it is to identify all places
where that housekeeping must be done, dunno. Surely you have an idea !


I had to rewrite the storage for the tags while switching to object
based
option parsing, and then noticed the linear search as well as lot of
tricky code.
The only idea that comes to mind is to keep a separate hash table that
maps
each tag to a list of items. I think the current hash table maps from
id (integers)
to item. By items I mean the memory address of the item struct.
tag -> {id1 id2 id3 ...}
Creating a new mapping item -> tagList then involves adding the item
to each tag hash entry. Removing a mapping item -> tagList would then
involve looking up the item and removing it for each tag hash entry.
This is a linear search which isn't good. Say that many items share a
common tag
and a tag hash entry has a long list of items. This would again make
it slow.

Seems we need a better idea.

Mats


.



Relevant Pages

  • Re: Porting Ruby snippet to Lisp
    ... Dispatch proceeds in 2 steps: ... Some OO languages directly tag each object with a pointer to its class ... hash or index on a suitable identity tag (if e.g., ... objects by address (heavier range comparison or hash) or you have more ...
    (comp.lang.lisp)
  • hashs and symbolic refrences
    ... sub ParseBIO{ ... they were recorded in the hash with their values. ... I found that I was using symbolic references quite by accident, ... The problem is that I am capturing only one tag ...
    (comp.lang.perl.misc)
  • Re: hashs and symbolic refrences
    ... [snip more of the same] ... To just add another key/value pair (and auto-vivify the hash reference the ... > I found that I was using symbolic references quite by accident, ... The problem is that I am capturing only one tag ...
    (comp.lang.perl.misc)
  • Re: checking hashref for value
    ... It turns XML into a nested hash ... structure where the hash values can be a hash reference, ... If a tag may be repeated ... ...
    (perl.beginners)
  • Re: Tk::Canvas (i) how to get an id? (ii) vertical text?
    ... First question to you: given a Canvas tag, how to find the id's of the ... Here is a Zinc rotate text. ...
    (comp.lang.perl.tk)