Move glcr::Array & glcr::ArrayView loops to range-based.
This commit is contained in:
		
							parent
							
								
									0a57d149b6
								
							
						
					
					
						commit
						5eb72da9c8
					
				|  | @ -194,8 +194,7 @@ template <typename K, typename V, class H> | ||||||
| void HashMap<K, V, H>::Resize(uint64_t new_size) { | void HashMap<K, V, H>::Resize(uint64_t new_size) { | ||||||
|   Array<LinkedList<Pair<K, V>>> new_data(new_size); |   Array<LinkedList<Pair<K, V>>> new_data(new_size); | ||||||
| 
 | 
 | ||||||
|   for (uint64_t i = 0; i < data_.size(); i++) { |   for (auto& ll : data_) { | ||||||
|     auto& ll = data_[i]; |  | ||||||
|     while (!ll.empty()) { |     while (!ll.empty()) { | ||||||
|       auto pair = ll.PopFront(); |       auto pair = ll.PopFront(); | ||||||
|       uint64_t hc = H()(pair.first()); |       uint64_t hc = H()(pair.first()); | ||||||
|  |  | ||||||
|  | @ -47,16 +47,16 @@ VariableMemoryObject::VariableMemoryObject(uint64_t size) : size_(size) { | ||||||
|   // FIXME: Do this lazily.
 |   // FIXME: Do this lazily.
 | ||||||
|   uint64_t num_pages = size_ / 0x1000; |   uint64_t num_pages = size_ / 0x1000; | ||||||
|   phys_page_list_ = glcr::Array<uint64_t>(num_pages); |   phys_page_list_ = glcr::Array<uint64_t>(num_pages); | ||||||
|   for (uint64_t i = 0; i < phys_page_list_.size(); i++) { |   for (uint64_t& page : phys_page_list_) { | ||||||
|     phys_page_list_[i] = 0; |     page = 0; | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| VariableMemoryObject::~VariableMemoryObject() { | VariableMemoryObject::~VariableMemoryObject() { | ||||||
|   for (uint64_t p = 0; p < phys_page_list_.size(); p++) { |   for (uint64_t& page : phys_page_list_) { | ||||||
|     if (phys_page_list_[p] != 0) { |     if (page != 0) { | ||||||
|       // TODO: We may be able to do some sort of coalescing here.
 |       // TODO: We may be able to do some sort of coalescing here.
 | ||||||
|       phys_mem::FreePage(phys_page_list_[p]); |       phys_mem::FreePage(page); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -28,12 +28,12 @@ glcr::ErrorOr<IpcMessage> TranslateRequestToIpcMessage(const T& req) { | ||||||
|   glcr::ArrayView<const z_cap_t> caps(req.caps, req.num_caps); |   glcr::ArrayView<const z_cap_t> caps(req.caps, req.num_caps); | ||||||
| 
 | 
 | ||||||
|   message.caps.Resize(caps.size()); |   message.caps.Resize(caps.size()); | ||||||
|   for (uint64_t i = 0; i < caps.size(); i++) { |   for (uint64_t capid : caps) { | ||||||
|     // FIXME: This would feel safer closer to the relevant syscall.
 |     // FIXME: This would feel safer closer to the relevant syscall.
 | ||||||
|     // FIXME: Race conditions on get->check->release here. Would be better to
 |     // FIXME: Race conditions on get->check->release here. Would be better to
 | ||||||
|     // have that as a single call on the process. (This pattern repeats other
 |     // have that as a single call on the process. (This pattern repeats other
 | ||||||
|     // places too).
 |     // places too).
 | ||||||
|     auto cap = gScheduler->CurrentProcess().GetCapability(caps[i]); |     auto cap = gScheduler->CurrentProcess().GetCapability(capid); | ||||||
|     if (!cap) { |     if (!cap) { | ||||||
|       return glcr::CAP_NOT_FOUND; |       return glcr::CAP_NOT_FOUND; | ||||||
|     } |     } | ||||||
|  | @ -41,7 +41,7 @@ glcr::ErrorOr<IpcMessage> TranslateRequestToIpcMessage(const T& req) { | ||||||
|       return glcr::CAP_PERMISSION_DENIED; |       return glcr::CAP_PERMISSION_DENIED; | ||||||
|     } |     } | ||||||
|     message.caps.PushBack( |     message.caps.PushBack( | ||||||
|         gScheduler->CurrentProcess().ReleaseCapability(caps[i])); |         gScheduler->CurrentProcess().ReleaseCapability(capid)); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   return message; |   return message; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue