When not using any arguments the current code executes and renders the same view output for every row in the parent view. Even when the parent view has regular caching enabled this still adds a lot of unnecessary code to the critical path. The attached patch adds a simple static caching layer.
This could potentially be extended to work with arguments also (by adding a 3rd dimension to the array), but that doesn't add any value unless you are adding fields multiple times (see idea in #1920730: Provide a way to retrieve values from field based views).
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 1920740-4.patch | 2.68 KB | damiankloip |
| static-cache.patch | 3.2 KB | owen barton |
Comments
Comment #1
damiankloip commentedI'm definitely not opposed to this idea!
We might as well just have this as a property on the class? Running is slightly different in that respect.
Comment #2
owen barton commentedWould moving it to the class make a difference in functionality, given that it is only used by the one function?
Comment #3
damiankloip commentedDoesn't matter that it's just used in one function I guess. It's just using a property on the class to do this instead of a static variable.
Comment #4
damiankloip commentedI was thinking something like this.
Comment #5
damiankloip commented#4: 1920740-4.patch queued for re-testing.
Comment #6
damiankloip commentedI've just gone ahead and committed the patch from #4, passes tests, and doesn't seem to break things :)