MCPcopy Create free account
hub / github.com/crawl/crawl / userfunc_getindex

Function userfunc_getindex

crawl-ref/source/macro.cc:182–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182static int userfunc_getindex(const string &fname)
183{
184 if (fname.length() == 0)
185 return -1;
186
187 userfunc_collectgarbage();
188
189 // Pass 1 to see if we have this string already
190 for (int i = 0, count = userfunctions.size(); i < count; ++i)
191 {
192 if (userfunctions[i] == fname)
193 return i;
194 }
195
196 // Pass 2 to hunt for gaps.
197 for (int i = 0, count = userfunctions.size(); i < count; ++i)
198 {
199 if (userfunctions[i].empty())
200 {
201 userfunctions[i] = fname;
202 return i;
203 }
204 }
205
206 userfunctions.push_back(fname);
207 return userfunctions.size() - 1;
208}
209
210// Returns the name of the file that contains macros.
211static string get_macro_file()

Callers 1

buf2keyseqFunction · 0.85

Calls 4

userfunc_collectgarbageFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected