Skip to content

Commit

Permalink
rx-html (internal): Reduce the memory consumption of RenderingContext (
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial authored Aug 4, 2023
1 parent 6790f14 commit 2d0538b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ object DOMRenderer extends LogSupport {
* document.
*/
private class RenderingContext() {
private val onRenderHooks = List.newBuilder[() => Unit]
private var onRenderHooks = List.empty[() => Unit]

def onFinish(): Unit = {
onRenderHooks.result().foreach { f => f() }
onRenderHooks.reverse.foreach { f => f() }
}

def addOnRenderHook(f: () => Unit): RenderingContext = {
onRenderHooks += f
onRenderHooks = f :: onRenderHooks
this
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ abstract class RxElement(val modifiers: List[Seq[HtmlNode]] = List.empty) extend
}

object RxElement {

def apply(a: RxElement): RxElement =
new RxElement() {
override def render: RxElement = a
Expand Down

0 comments on commit 2d0538b

Please sign in to comment.