Skip to content

Commit

Permalink
Simplify DiffBuilder interface
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankoegl committed Jan 5, 2018
1 parent 1d89ec3 commit f301608
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions jsonpatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ def from_diff(cls, src, dst, optimization=True):
True
"""

builder = DiffBuilder()
builder._compare_values('', None, src, dst)
builder = DiffBuilder(src, dst)
ops = list(builder.execute())
return cls(ops)

Expand Down Expand Up @@ -625,7 +624,9 @@ def apply(self, obj):

class DiffBuilder(object):

def __init__(self):
def __init__(self, src, dst):
self.src = src
self.dst = dst
self.index_storage = [{}, {}]
self.index_storage2 = [[], []]
self.__root = root = []
Expand Down Expand Up @@ -682,6 +683,8 @@ def __iter__(self):
curr = curr[1]

def execute(self):
self._compare_values('', None, self.src, self.dst)

root = self.__root
curr = root[1]
while curr is not root:
Expand Down

0 comments on commit f301608

Please sign in to comment.