mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 07:32:44 +00:00 
			
		
		
		
	Kernel/ProcFS: Avoid two unnecessary number-to-string conversions
We don't need to create a new string from a number in order to compare an existing string to that number. Converting the existing string to a number is much cheaper, since it does not require any heap allocations. Ran into this while profiling "find /" :^)
This commit is contained in:
		
							parent
							
								
									9c373b646b
								
							
						
					
					
						commit
						a412fd2ed8
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		|  | @ -61,7 +61,7 @@ KResultOr<NonnullRefPtr<Inode>> Process::lookup_stacks_directory(const ProcFS& p | |||
|     for_each_thread([&](const Thread& thread) { | ||||
|         int tid = thread.tid().value(); | ||||
|         VERIFY(!(tid < 0)); | ||||
|         if (name == String::number(tid)) { | ||||
|         if (name.to_int() == tid) { | ||||
|             auto maybe_inode = ProcFSProcessPropertyInode::try_create_for_thread_stack(procfs, thread.tid(), pid()); | ||||
|             if (maybe_inode.is_error()) { | ||||
|                 thread_stack_inode = maybe_inode.error(); | ||||
|  | @ -114,7 +114,7 @@ KResultOr<NonnullRefPtr<Inode>> Process::lookup_file_descriptions_directory(cons | |||
|             count++; | ||||
|             return; | ||||
|         } | ||||
|         if (name == String::number(count)) { | ||||
|         if (name.to_uint() == count) { | ||||
|             auto maybe_inode = ProcFSProcessPropertyInode::try_create_for_file_description_link(procfs, static_cast<unsigned>(count), pid()); | ||||
|             if (maybe_inode.is_error()) { | ||||
|                 file_description_link = maybe_inode.error(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling