mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Preallocate memory when deriving address from key
This makes src/address.AddrForKey preallocate 32 bytes before starting the address derivation. As benches in syg_go show, reallocating temp takes 20% of the function runtime.
This commit is contained in:
		
							parent
							
								
									35e8ff7c9d
								
							
						
					
					
						commit
						04ecdf6045
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -64,7 +64,7 @@ func AddrForKey(publicKey ed25519.PublicKey) *Address {
 | 
			
		|||
		buf[idx] = ^buf[idx]
 | 
			
		||||
	}
 | 
			
		||||
	var addr Address
 | 
			
		||||
	var temp []byte
 | 
			
		||||
	var temp = make([]byte, 0, 32)
 | 
			
		||||
	done := false
 | 
			
		||||
	ones := byte(0)
 | 
			
		||||
	bits := byte(0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue