Skip to content
This repository has been archived by the owner. It is now read-only.

Diff algorithm preforms poorly on prepend #66

Closed
OlivierBlanvillain opened this issue Feb 3, 2017 · 1 comment
Closed

Diff algorithm preforms poorly on prepend #66

OlivierBlanvillain opened this issue Feb 3, 2017 · 1 comment

Comments

@OlivierBlanvillain
Copy link

OlivierBlanvillain commented Feb 3, 2017

The diff algorithm works fine when appending:

val a = 'div (
  'h2 /= "", 'h1 /= "", 'h2 /= "", 'h1 /= "", 'h2 /= "", 'h1 /= "", 'h2 /= "")

val b = 'div (
  'h2 /= "", 'h1 /= "", 'h2 /= "", 'h1 /= "", 'h2 /= "", 'h1 /= "", 'h2 /= "",
  'h1 /= "new")
  
VDom.changes(a, b) == List(SetAttr(0,"h1","new",false))

But seams to preform poorly when prepending:

val a = 'div (
  'h2 /= "", 'h1 /= "", 'h2 /= "", 'h1 /= "", 'h2 /= "", 'h1 /= "", 'h2 /= "")

val b = 'div (
  'h1 /= "new",
  'h2 /= "", 'h1 /= "", 'h2 /= "", 'h1 /= "", 'h2 /= "", 'h1 /= "", 'h2 /= "")

VDom.changes(a, b) == List(
  SetAttr(0,"h2","",false),
  RemoveAttr(0,"h2",""false),
  SetAttr(0,"h1","",false),
  RemoveAttr(0,"h1",""false),
  SetAttr(0,"h2","",false),
  RemoveAttr(0,"h2",""false),
  SetAttr(0,"h1","",false),
  RemoveAttr(0,"h1",""false),
  SetAttr(0,"h2","",false),
  RemoveAttr(0,"h2",""false),
  SetAttr(0,"h1","",false),
  RemoveAttr(0,"h1",""false),
  SetAttr(0,"h2","",false),
  RemoveAttr(0,"h2",""false),
  SetAttr(0,"h1","new",false)
)

FWIW the kivi implementation seams to hande these cases while remaining reasonably simple

@fomkin
Copy link
Owner

fomkin commented Jul 1, 2017

Solved #120

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants