Performance optimization: Only write new ZipFile, if it has been changed. The test suite runs in half the time now.
This commit is contained in:
parent
63520661b1
commit
0c1350ec86
7
zip.rb
7
zip.rb
|
|
@ -759,6 +759,8 @@ module Zip
|
|||
else
|
||||
raise ZipError, "File #{fileName} not found"
|
||||
end
|
||||
@create = create
|
||||
@storedEntries = @entries.map{ |e| e.dup }
|
||||
end
|
||||
|
||||
def ZipFile.open(fileName, create = nil)
|
||||
|
|
@ -829,6 +831,7 @@ module Zip
|
|||
end
|
||||
|
||||
def commit
|
||||
return if ! commitRequired?
|
||||
onSuccessReplace(name) {
|
||||
|tmpFile|
|
||||
ZipOutputStream.open(tmpFile) {
|
||||
|
|
@ -845,6 +848,10 @@ module Zip
|
|||
def close
|
||||
commit
|
||||
end
|
||||
|
||||
def commitRequired?
|
||||
return entries != @storedEntries || @create == ZipFile::CREATE
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue