mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:42:44 +00:00 
			
		
		
		
	AK+Kernel+LibELF: Remove the need for IteratorDecision::Continue
				
					
				
			By constraining two implementations, the compiler will select the best fitting one. All this will require is duplicating the implementation and simplifying for the `void` case. This constraining also informs both the caller and compiler by passing the callback parameter types as part of the constraint (e.g.: `IterationFunction<int>`). Some `for_each` functions in LibELF only take functions which return `void`. This is a minimal correctness check, as it removes one way for a function to incompletely do something. There seems to be a possible idiom where inside a lambda, a `return;` is the same as `continue;` in a for-loop.
This commit is contained in:
		
							parent
							
								
									bbaa463032
								
							
						
					
					
						commit
						aa4d41fe2c
					
				
					 25 changed files with 311 additions and 127 deletions
				
			
		|  | @ -688,7 +688,7 @@ static bool procfs$cpuinfo(InodeIdentifier, KBufferBuilder& builder) | |||
| { | ||||
|     JsonArraySerializer array { builder }; | ||||
|     Processor::for_each( | ||||
|         [&](Processor& proc) -> IterationDecision { | ||||
|         [&](Processor& proc) { | ||||
|             auto& info = proc.info(); | ||||
|             auto obj = array.add_object(); | ||||
|             JsonArray features; | ||||
|  | @ -702,7 +702,6 @@ static bool procfs$cpuinfo(InodeIdentifier, KBufferBuilder& builder) | |||
|             obj.add("stepping", info.stepping()); | ||||
|             obj.add("type", info.type()); | ||||
|             obj.add("brandstr", info.brandstr()); | ||||
|             return IterationDecision::Continue; | ||||
|         }); | ||||
|     array.finish(); | ||||
|     return true; | ||||
|  | @ -826,7 +825,6 @@ static bool procfs$all(InodeIdentifier, KBufferBuilder& builder) | |||
|             thread_object.add("unix_socket_write_bytes", thread.unix_socket_write_bytes()); | ||||
|             thread_object.add("ipv4_socket_read_bytes", thread.ipv4_socket_read_bytes()); | ||||
|             thread_object.add("ipv4_socket_write_bytes", thread.ipv4_socket_write_bytes()); | ||||
|             return IterationDecision::Continue; | ||||
|         }); | ||||
|     }; | ||||
| 
 | ||||
|  | @ -1328,10 +1326,9 @@ KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntr | |||
|         auto process = Process::from_pid(pid); | ||||
|         if (!process) | ||||
|             return ENOENT; | ||||
|         process->for_each_thread([&](const Thread& thread) -> IterationDecision { | ||||
|         process->for_each_thread([&](const Thread& thread) { | ||||
|             int tid = thread.tid().value(); | ||||
|             callback({ String::number(tid), to_identifier_with_stack(fsid(), tid), 0 }); | ||||
|             return IterationDecision::Continue; | ||||
|         }); | ||||
|     } break; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nicholas Baron
						Nicholas Baron