refactor(3p/nix): Rename & undeprecate Bindings::lexicographicOrder
The function is renamed to `SortedByKeys`, which is more descriptive, and annotated with a comment about what it is used for. The deprecation warning has been removed because this function is currently functionally required. Change-Id: I0ee3a76deff05f366feca9ddac8f38ab34bffbd0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1288 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
		
							parent
							
								
									02066a4bab
								
							
						
					
					
						commit
						324d385b29
					
				
					 5 changed files with 10 additions and 6 deletions
				
			
		
							
								
								
									
										2
									
								
								third_party/nix/src/libexpr/attr-set.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								third_party/nix/src/libexpr/attr-set.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -37,7 +37,7 @@ size_t Bindings::size() const { return attributes_.size(); } | |||
| 
 | ||||
| bool Bindings::empty() { return attributes_.empty(); } | ||||
| 
 | ||||
| std::vector<const Attr*> Bindings::lexicographicOrder() { | ||||
| std::vector<const Attr*> Bindings::SortedByKeys() { | ||||
|   std::vector<const Attr*> res; | ||||
|   res.reserve(attributes_.size()); | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										8
									
								
								third_party/nix/src/libexpr/attr-set.hh
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								third_party/nix/src/libexpr/attr-set.hh
									
										
									
									
										vendored
									
									
								
							|  | @ -55,8 +55,12 @@ class Bindings { | |||
|   iterator begin(); | ||||
|   iterator end(); | ||||
| 
 | ||||
|   // TODO: can callers just iterate?
 | ||||
|   [[deprecated]] std::vector<const Attr*> lexicographicOrder(); | ||||
|   // Returns the elements of the attribute set as a vector, sorted
 | ||||
|   // lexicographically by keys.
 | ||||
|   //
 | ||||
|   // This is used primarily for builtins that have guaranteed
 | ||||
|   // ordering, such as `attrNames` or `attrValues`.
 | ||||
|   std::vector<const Attr*> SortedByKeys(); | ||||
| 
 | ||||
|   // oh no
 | ||||
|   friend class EvalState; | ||||
|  |  | |||
							
								
								
									
										2
									
								
								third_party/nix/src/libexpr/eval.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								third_party/nix/src/libexpr/eval.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -89,7 +89,7 @@ static void printValue(std::ostream& str, std::set<const Value*>& active, | |||
|       break; | ||||
|     case tAttrs: { | ||||
|       str << "{ "; | ||||
|       for (auto& i : v.attrs->lexicographicOrder()) { | ||||
|       for (auto& i : v.attrs->SortedByKeys()) { | ||||
|         str << i->name << " = "; | ||||
|         printValue(str, active, *i->value); | ||||
|         str << "; "; | ||||
|  |  | |||
							
								
								
									
										2
									
								
								third_party/nix/src/libexpr/get-drvs.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								third_party/nix/src/libexpr/get-drvs.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -387,7 +387,7 @@ static void getDerivations(EvalState& state, Value& vIn, | |||
|        there are names clashes between derivations, the derivation | ||||
|        bound to the attribute with the "lower" name should take | ||||
|        precedence). */ | ||||
|     for (auto& i : v.attrs->lexicographicOrder()) { | ||||
|     for (auto& i : v.attrs->SortedByKeys()) { | ||||
|       DLOG(INFO) << "evaluating attribute '" << i->name << "'"; | ||||
|       if (!std::regex_match(std::string(i->name), attrRegex)) { | ||||
|         continue; | ||||
|  |  | |||
							
								
								
									
										2
									
								
								third_party/nix/src/libexpr/primops.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								third_party/nix/src/libexpr/primops.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -561,7 +561,7 @@ static void prim_derivationStrict(EvalState& state, const Pos& pos, | |||
|   StringSet outputs; | ||||
|   outputs.insert("out"); | ||||
| 
 | ||||
|   for (auto& i : args[0]->attrs->lexicographicOrder()) { | ||||
|   for (auto& i : args[0]->attrs->SortedByKeys()) { | ||||
|     if (i->name == state.sIgnoreNulls) { | ||||
|       continue; | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue