================ @@ -107,15 +107,28 @@ CXString createCXString(CXStringBuf *buf) { return Str; } -CXStringSet *createSet(const std::vector<std::string> &Strings) { +template <typename StringTy, bool Copy> +static CXStringSet *createSetImpl(ArrayRef<StringTy> Strings) { CXStringSet *Set = new CXStringSet; Set->Count = Strings.size(); Set->Strings = new CXString[Set->Count]; - for (unsigned SI = 0, SE = Set->Count; SI < SE; ++SI) - Set->Strings[SI] = createDup(Strings[SI]); + for (unsigned SI = 0, SE = Set->Count; SI < SE; ++SI) { + if constexpr (Copy) { + Set->Strings[SI] = createDup(Strings[SI]); + } else { + Set->Strings[SI] = createRef(Strings[SI]); + } + } return Set; } +CXStringSet *createSet(const std::vector<std::string> &Strings) { + return createSetImpl<std::string, true>(ArrayRef<std::string>(Strings)); ---------------- jansvoboda11 wrote:
Nit: With the `StringTy` template parameter specified explicitly, I don't think you need to explicitly call the `ArrayRef` constructor here. The one from `const std::vector &` is implicit, so it will get called automatically. https://github.com/llvm/llvm-project/pull/136773 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits