handlebars-rust icon indicating copy to clipboard operation
handlebars-rust copied to clipboard

Implement block-scoped inline partials

Open YannikSc opened this issue 8 months ago • 3 comments

This is my attempt in fixing #704.

My attempt definitely opened #495 and #693 again, but copying the hash_ctx to the block_params worked around this. I'm not sure if the performance hit is acceptable, but at least it fixes a scoping issue.

cargo bench with the change

parse_template          time:   [49.531 µs 49.542 µs 49.553 µs]
                        change: [+1.7350% +2.2424% +2.5788%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 6 outliers among 100 measurements (6.00%)
  3 (3.00%) high mild
  3 (3.00%) high severe

render_template         time:   [5.5300 µs 5.5320 µs 5.5342 µs]
                        change: [+1.4191% +1.4921% +1.5621%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) low mild
  1 (1.00%) high severe

large_loop_helper       time:   [393.91 µs 394.10 µs 394.31 µs]
                        change: [+1.3439% +1.4332% +1.5314%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 6 outliers among 100 measurements (6.00%)
  4 (4.00%) high mild
  2 (2.00%) high severe

large_loop_helper_with_context_creation
                        time:   [921.40 µs 921.64 µs 921.85 µs]
                        change: [-0.5717% -0.5299% -0.4944%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 8 outliers among 100 measurements (8.00%)
  1 (1.00%) low severe
  6 (6.00%) low mild
  1 (1.00%) high severe

large_nested_loop       time:   [442.45 µs 442.65 µs 442.85 µs]
                        change: [+0.4180% +1.0867% +1.5428%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 5 outliers among 100 measurements (5.00%)
  1 (1.00%) low severe
  1 (1.00%) low mild
  3 (3.00%) high mild

deeply_nested_partial   time:   [566.47 µs 566.61 µs 566.76 µs]
                        change: [-1.3247% -1.2691% -1.2158%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high severe

cargo bench before the change

parse_template          time:   [48.279 µs 48.432 µs 48.695 µs]
Found 5 outliers among 100 measurements (5.00%)
  3 (3.00%) high mild
  2 (2.00%) high severe

render_template         time:   [5.4495 µs 5.4524 µs 5.4561 µs]
Found 8 outliers among 100 measurements (8.00%)
  1 (1.00%) low severe
  4 (4.00%) low mild
  1 (1.00%) high mild
  2 (2.00%) high severe

large_loop_helper       time:   [388.87 µs 389.04 µs 389.24 µs]
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) high mild
  3 (3.00%) high severe

large_loop_helper_with_context_creation
                        time:   [926.07 µs 926.30 µs 926.58 µs]
Found 7 outliers among 100 measurements (7.00%)
  4 (4.00%) low mild
  3 (3.00%) high severe

large_nested_loop       time:   [435.40 µs 437.35 µs 439.82 µs]
Found 9 outliers among 100 measurements (9.00%)
  2 (2.00%) high mild
  7 (7.00%) high severe

deeply_nested_partial   time:   [573.57 µs 573.75 µs 573.96 µs]
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe

YannikSc avatar Apr 17 '25 21:04 YannikSc

Coverage Status

coverage: 82.307% (-0.2%) from 82.552% when pulling 542abac130619a28d2714734f5e2842ca2d63841 on YannikSc:master into 4bf34dab4c4fd796b837d55a0fdd1162c98cb2f6 on sunng87:master.

coveralls avatar Apr 18 '25 02:04 coveralls

@YannikSc thank you for the patch. I'm so sorry for the delay of review. I'm getting super busy these days and I will find time to look into this.

sunng87 avatar May 21 '25 07:05 sunng87

Hey, no worries I'm running on my fork for now, which works for me for now, keep your time

YannikSc avatar May 27 '25 14:05 YannikSc