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:
thomas 2002-03-29 16:50:36 +00:00
parent 63520661b1
commit 0c1350ec86
1 changed files with 7 additions and 0 deletions

7
zip.rb
View File

@ -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