mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 06:15:20 +00:00 
			
		
		
		
	refactor CompareLsCompletionItem (#412)
Since not everything is a reference, std::make_tuple() seems more appropriate than std::tie(). For heavy types, std::cref() can be used to preserve the reference.
This commit is contained in:
		
							parent
							
								
									24702a25b0
								
							
						
					
					
						commit
						65d7edd9b9
					
				@ -70,16 +70,12 @@ MAKE_REFLECT_STRUCT(Out_TextDocumentComplete, jsonrpc, id, result);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
bool CompareLsCompletionItem(const lsCompletionItem& lhs,
 | 
					bool CompareLsCompletionItem(const lsCompletionItem& lhs,
 | 
				
			||||||
                             const lsCompletionItem& rhs) {
 | 
					                             const lsCompletionItem& rhs) {
 | 
				
			||||||
  bool lhsNotFound = !lhs.found_;
 | 
					  return std::make_tuple(!lhs.found_, lhs.skip_, lhs.priority_,
 | 
				
			||||||
  bool rhsNotFound = !rhs.found_;
 | 
					                         lhs.filterText.length(), std::cref(lhs.filterText),
 | 
				
			||||||
  const auto lhsFilterTextLength = lhs.filterText.length();
 | 
					                         lhs.label.length(), std::cref(lhs.label)) <
 | 
				
			||||||
  const auto lhsLabelLength = lhs.label.length();
 | 
					         std::make_tuple(!rhs.found_, rhs.skip_, rhs.priority_,
 | 
				
			||||||
  const auto rhsFilterTextLength = rhs.filterText.length();
 | 
					                         rhs.filterText.length(), std::cref(rhs.filterText),
 | 
				
			||||||
  const auto rhsLabelLength = rhs.label.length();
 | 
					                         rhs.label.length(), std::cref(rhs.label));
 | 
				
			||||||
  return std::tie(lhsNotFound, lhs.skip_, lhs.priority_, lhsFilterTextLength,
 | 
					 | 
				
			||||||
                  lhs.filterText, lhsLabelLength, lhs.label) <
 | 
					 | 
				
			||||||
         std::tie(rhsNotFound, rhs.skip_, rhs.priority_, rhsFilterTextLength,
 | 
					 | 
				
			||||||
                  rhs.filterText, rhsLabelLength, lhs.label);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <typename T>
 | 
					template <typename T>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user