-
Notifications
You must be signed in to change notification settings - Fork 220
Pool TagHelperExecutionContext
s within TagHelperScopeManager
.
#695
Conversation
} | ||
|
||
// Used to pool TagHelperExecutionContext's. With this we don't always need to recreate TagHelperExecutionContexts. | ||
internal void ClearAndUpdateWith( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reset(...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why internal? Would user code ever see this type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, user code wont see this type. As for Reset
, that was my first naming of this but felt that the name mislead with what it really did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest Reinitialize()
. Also suggest public
because internal
is used only for bits that would be private
if not for testing. (All of Microsoft.AspNetCore.Razor.Runtime.TagHelpers
could be named .Internal
if we wanted.)
65d8462
to
1e73a71
Compare
🆙 📅 |
/// <param name="items">The <see cref="IDictionary{Object, Object}"/> to use.</param> | ||
/// <param name="uniqueId">The unique id to use.</param> | ||
/// <param name="executeChildContentAsync">The <see cref="Func{Task}"/> to use.</param> | ||
public void Reinitialize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest removing overlapping parameters from the constructors, requiring a Reinitialize()
call for all uses. Alternatively call Reinitialize()
from the constructors duplicating this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx
⌚ (looking very solid) |
🆙 📅 |
throw new ArgumentNullException(nameof(endTagHelperWritingScope)); | ||
} | ||
|
||
Reinitialize(tagName, tagMode, items, uniqueId, executeChildContentAsync); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call this after initializing _tagHelpers
and just .Clear()
that field in Reinitialize()
.
Not urgent to check but am curious whether |
|
- Currently the `TagHelperScopeManager` creates a new `TagHelperExecutionContext` per `TagHelper` on a given page. With this change the max number of `TagHelperExecutionContext`s per page is the number of nested levels that exist. - Added two tests validating that specific pieces of `TagHelperExecutionContext` are updated as expected. #674
d902fe4
to
78451ef
Compare
TagHelperScopeManager
creates a newTagHelperExecutionContext
perTagHelper
on a given page. With this change the max number ofTagHelperExecutionContext
s per page is the number of nested levels that exist.TagHelperExecutionContext
are updated as expected.Before:

After:

Result: 3% overall reduction in allocations.
#674