File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -107,22 +107,27 @@ CXString createCXString(CXStringBuf *buf) {
107107 return Str;
108108}
109109
110- template <typename StringTy>
111- static CXStringSet *createSetImpl (const std::vector <StringTy> & Strings) {
110+ template <typename StringTy, bool Copy >
111+ static CXStringSet *createSetImpl (ArrayRef <StringTy> Strings) {
112112 CXStringSet *Set = new CXStringSet;
113113 Set->Count = Strings.size ();
114114 Set->Strings = new CXString[Set->Count ];
115- for (unsigned SI = 0 , SE = Set->Count ; SI < SE; ++SI)
116- Set->Strings [SI] = createDup (Strings[SI]);
115+ for (unsigned SI = 0 , SE = Set->Count ; SI < SE; ++SI) {
116+ if constexpr (Copy) {
117+ Set->Strings [SI] = createDup (Strings[SI]);
118+ } else {
119+ Set->Strings [SI] = createRef (Strings[SI]);
120+ }
121+ }
117122 return Set;
118123}
119124
120125CXStringSet *createSet (const std::vector<std::string> &Strings) {
121- return createSetImpl ( Strings);
126+ return createSetImpl<std::string, true >(ArrayRef<std::string>( Strings) );
122127}
123128
124- CXStringSet *createSet ( const std::vector <StringRef> & Strings) {
125- return createSetImpl (Strings);
129+ CXStringSet *createRefSet (ArrayRef <StringRef> Strings) {
130+ return createSetImpl<StringRef, false > (Strings);
126131}
127132
128133// ===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments