mirror of https://github.com/webpack/webpack.git
				
				
				
			inline flush, reduce bulk size
This commit is contained in:
		
							parent
							
								
									a0ef93f939
								
							
						
					
					
						commit
						6b40b1699e
					
				|  | @ -4,7 +4,7 @@ | |||
| */ | ||||
| "use strict"; | ||||
| 
 | ||||
| const BULK_SIZE = 10000; | ||||
| const BULK_SIZE = 1000; | ||||
| 
 | ||||
| class BulkUpdateDecorator { | ||||
| 	constructor(hash) { | ||||
|  | @ -14,26 +14,25 @@ class BulkUpdateDecorator { | |||
| 
 | ||||
| 	update(data, inputEncoding) { | ||||
| 		if(inputEncoding !== undefined || typeof data !== "string" || data.length > BULK_SIZE) { | ||||
| 			if(this.buffer.length > 0) | ||||
| 				this._flush(); | ||||
| 			if(this.buffer.length > 0) { | ||||
| 				this.hash.update(this.buffer); | ||||
| 				this.buffer = ""; | ||||
| 			} | ||||
| 			this.hash.update(data, inputEncoding); | ||||
| 		} else { | ||||
| 			this.buffer += data; | ||||
| 			if(this.buffer.length > BULK_SIZE) { | ||||
| 				this._flush(); | ||||
| 				this.hash.update(this.buffer); | ||||
| 				this.buffer = ""; | ||||
| 			} | ||||
| 		} | ||||
| 		return this; | ||||
| 	} | ||||
| 
 | ||||
| 	_flush() { | ||||
| 		this.hash.update(this.buffer); | ||||
| 		this.buffer = ""; | ||||
| 	} | ||||
| 
 | ||||
| 	digest(encoding) { | ||||
| 		if(this.buffer.length > 0) | ||||
| 			this._flush(); | ||||
| 		if(this.buffer.length > 0) { | ||||
| 			this.hash.update(this.buffer); | ||||
| 		} | ||||
| 		return this.hash.digest(encoding); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue