mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 01:22:43 +00:00 
			
		
		
		
	LibWasm: Don't create useless temporary strings for trap reasons
These strings are only used when execution traps, so there's no reason to create actual strings until that happens; instead switch to using StringViews.
This commit is contained in:
		
							parent
							
								
									2fc0040ceb
								
							
						
					
					
						commit
						06ffc0c4db
					
				
					 2 changed files with 4 additions and 4 deletions
				
			
		|  | @ -17,7 +17,7 @@ namespace Wasm { | |||
| 
 | ||||
| #define TRAP_IF_NOT(x)                                                                         \ | ||||
|     do {                                                                                       \ | ||||
|         if (trap_if_not(x, #x)) {                                                              \ | ||||
|         if (trap_if_not(x, #x##sv)) {                                                          \ | ||||
|             dbgln_if(WASM_TRACE_DEBUG, "Trapped because {} failed, at line {}", #x, __LINE__); \ | ||||
|             return;                                                                            \ | ||||
|         }                                                                                      \ | ||||
|  | @ -25,7 +25,7 @@ namespace Wasm { | |||
| 
 | ||||
| #define TRAP_IF_NOT_NORETURN(x)                                                                \ | ||||
|     do {                                                                                       \ | ||||
|         if (trap_if_not(x, #x)) {                                                              \ | ||||
|         if (trap_if_not(x, #x##sv)) {                                                          \ | ||||
|             dbgln_if(WASM_TRACE_DEBUG, "Trapped because {} failed, at line {}", #x, __LINE__); \ | ||||
|         }                                                                                      \ | ||||
|     } while (false) | ||||
|  |  | |||
|  | @ -49,10 +49,10 @@ protected: | |||
|     T read_value(ReadonlyBytes data); | ||||
| 
 | ||||
|     Vector<Value> pop_values(Configuration& configuration, size_t count); | ||||
|     bool trap_if_not(bool value, String reason) | ||||
|     bool trap_if_not(bool value, StringView reason) | ||||
|     { | ||||
|         if (!value) | ||||
|             m_trap = Trap { move(reason) }; | ||||
|             m_trap = Trap { reason }; | ||||
|         return m_trap.has_value(); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ali Mohammad Pur
						Ali Mohammad Pur