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) {
 | 
			
		||||
| 
						 | 
				
			
			@ -846,6 +849,10 @@ module Zip
 | 
			
		|||
      commit
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def commitRequired?
 | 
			
		||||
      return entries != @storedEntries || @create == ZipFile::CREATE
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    private
 | 
			
		||||
 | 
			
		||||
    def createDirectory(entry, destPath)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue