Skip to content

Commit

Permalink
remove o(n^2) path
Browse files Browse the repository at this point in the history
  • Loading branch information
rozap committed Jan 28, 2020
1 parent 4e18fe1 commit 4e3590b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions socrata/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,18 @@ def read(self, how_much):
if self.done:
return None

buf = b''
while len(buf) < how_much:
buf = []
consumed = 0
while consumed < how_much:
try:
buf = buf + next(self.gen)
chunk = next(self.gen)
consumed += len(chunk)
buf.append(chunk)
except StopIteration:
self.done = True
break
return buf

return b''.join(buf)


class Source(Resource, ParseOptionBuilder):
Expand Down

0 comments on commit 4e3590b

Please sign in to comment.