maqetta/maqetta — Issue #1845: Inefficient (bad?) theme code in Context._setSourceData
Author: jhpedemonte
Created: 2012-03-02 17:55:27+00:00
State: open
Labels: Performance, Priority Med

`Context._setSourceData()` has some theme code which is very odd, and also inefficient. This theme code is invoked whenever the source is changed (user editing in source mode) or when doing the "refresh from source" path.

1. When invoking `_setSourceData()`, the function `themeChanged()` is always called. It does a `model.find()` for a CSS import of *"themes/claro/claro.css"* and **always fails** (even though the source does have an import for that CSS file). This means that `_themeMetaCache` is set to `null` **every time the source is reset**.
2. Because `_themeMetaCache` is always set to `null`, this eventually leads to always calling `metadata.loadThemeMeta`, which again does a `model.find`, amongst other things.

Overall, this code needs to be rewritten -- there is **no reason to always load the Theme files when the user has only changed a bit of the source**. We need to be smarter about this.

(Assigning to @peller for now, since this is performance-related. But may need to be fixed by @billreed63)