Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
nvidia-patch
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
nvidia-patch
Commits
375972f1
Commit
375972f1
authored
Feb 06, 2019
by
Vladislav Yarmak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1337-diff: 3x speed improvement
parent
0fa7df74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
win/tools/1337-diff/1337-diff.py
win/tools/1337-diff/1337-diff.py
+11
-6
No files found.
win/tools/1337-diff/1337-diff.py
View file @
375972f1
...
@@ -64,24 +64,29 @@ def feed_chunks(f, chunk_size=4096):
...
@@ -64,24 +64,29 @@ def feed_chunks(f, chunk_size=4096):
yield
buf
yield
buf
def
zip_files_bytes
(
*
files
):
def
zip_files_bytes
(
left
,
right
):
""" Iterate over two files, returning pair of bytes.
""" Iterate over two files, returning pair of bytes.
Throw LengthMismatch if file sizes is uneven. """
Throw LengthMismatch if file sizes is uneven. """
class
EndMarker
(
object
):
class
EndMarker
(
object
):
pass
pass
end_marker
=
EndMarker
()
end_marker
=
EndMarker
()
iterators
=
(
itertools
.
chain
.
from_iterable
(
feed_chunks
(
f
))
for
f
in
files
)
left_iter
=
itertools
.
chain
.
from_iterable
(
feed_chunks
(
left
))
for
tup
in
itertools
.
zip_longest
(
*
iterators
,
fillvalue
=
end_marker
):
right_iter
=
itertools
.
chain
.
from_iterable
(
feed_chunks
(
right
))
if
any
(
v
is
end_marker
for
v
in
tup
):
for
a
,
b
in
itertools
.
zip_longest
(
left_iter
,
right_iter
,
fillvalue
=
end_marker
):
if
a
is
end_marker
or
b
is
end_marker
:
raise
LengthMismatchException
(
"Length of input files inequal."
)
raise
LengthMismatchException
(
"Length of input files inequal."
)
yield
tup
yield
a
,
b
def
diff
(
left
,
right
):
def
diff
(
left
,
right
):
for
offset
,
(
a
,
b
)
in
enumerate
(
zip_files_bytes
(
left
,
right
)):
offset
=
0
for
a
,
b
in
zip_files_bytes
(
left
,
right
):
if
a
!=
b
:
if
a
!=
b
:
yield
offset
,
a
,
b
yield
offset
,
a
,
b
offset
+=
1
def
compose_diff_file
(
orig
,
patched
,
output
,
header
,
offset_adjustment
=
True
):
def
compose_diff_file
(
orig
,
patched
,
output
,
header
,
offset_adjustment
=
True
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment