You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(template): add render_once() for optimized single-render scenarios
Add render_once() method that takes ownership of the schema instead of
cloning it, providing significant performance improvements for large
schemas (up to 10x faster for 1000+ keys).
- Add render_once() public method with comprehensive documentation
- Add init_render_once() internal helper using mem::take
- Add unit tests for render_once() functionality
- Add performance comparison benchmarks
- Document usage guidelines and performance characteristics in README
This is ideal for web applications where templates are rendered once
per request and then discarded.
Copy file name to clipboardExpand all lines: README.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,28 @@ The IPC approach introduces performance overhead due to inter-process communicat
85
85
86
86
For most web applications, the security and interoperability benefits compensate for the performance overhead.
87
87
88
+
### **Optimizing First Render (Large Schemas):**
89
+
90
+
When working with large schemas (thousands of keys), the first render can be optimized using `render_once()` instead of `render()`. This method takes ownership of the schema instead of cloning it, providing significant performance improvements:
- Single render per template instance (most common use case)
101
+
- Large schemas with thousands of keys
102
+
- Memory-constrained environments
103
+
104
+
**When NOT to use `render_once()`:**
105
+
- Multiple renders from the same template instance
106
+
- Template reuse scenarios
107
+
108
+
After `render_once()`, the template cannot be reused because the schema is consumed. Use `render()` for reusable templates.
109
+
88
110
### **IPC Components:**
89
111
-**IPC Server**: Universal standalone application (written in Rust) for all languages - download from: [IPC Server](https://github.com/FranBarInstance/neutral-ipc/releases)
90
112
-**IPC Clients**: Language-specific libraries to include in your project - available at: [IPC Clients](https://github.com/FranBarInstance/neutral-ipc/tree/master/clients)
0 commit comments