Difference between revisions of "Caching"

From Inkscape Wiki
Jump to: navigation, search
(create discussion page on caching)
(No difference)

Revision as of 18:10, 31 August 2011


This page is for notes in the discussion on adding caching to Inkscape for a performance boost. It started from a note on caching an item's bounding box (end of Aug 2011).

What to cache

(please write down which object type the data should belong to)

  • SPItem bounding box
    • should invalidate on probably all changes
  • SPShape conversion to SBasis (2geom path data)
    • should invalidate on path data and transform change
  • SPLPEItem, LPE intermediate data (related to the input path, this requires some architectural changes in LPE code)
    • invalidates on path data change
  • LivePathEffect::Parameter
    • intermediate results, like arc-length-reparametrisation for LPE-Bend
    • LivePathEffect::PathParam already caches the conversion to pwd2

Perhaps it is best to start implementing this by invalidating the full cache for an object if any change on it is detected?

Cache class

A Cache object class that can be added to objects that need a cache. Each object then has its own cache, so no clashing of itemnames in the cache etc. The item's cache object can be publicly accessible for some classes, and is private in other classes, right?

How about these methods:

  • addValue( string key, any value )
    • adds an item to the cache, could be any type of data (?)
  • retrieve( string key )
    • returns optional value. Must work out how to return "no value found".
  • invalidate( string key )
    • invalidates named entry, or all entries when string is NULL or "all" ?