MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / FindLabel

Method FindLabel

source/script.cpp:4151–4168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4149
4150
4151Label *Script::FindLabel(LPTSTR aLabelName)
4152// Returns the first label whose name matches aLabelName, or NULL if not found.
4153
4154// If duplicates labels are now possible, callers must be aware that only the first match is returned.
4155// This helps performance by requiring on average only half the labels to be searched before
4156// a match is found.
4157{
4158 if (!aLabelName || !*aLabelName) return NULL;
4159 Label *label;
4160 if (g->CurrentFunc)
4161 label = g->CurrentFunc->mFirstLabel; // Search only local labels, since global labels aren't valid jump targets in this case.
4162 else
4163 label = mFirstLabel;
4164 for ( ; label; label = label->mNextLabel)
4165 if (!_tcsicmp(label->mName, aLabelName)) // lstrcmpi() is not used: 1) avoids breaking existing scripts; 2) provides consistent behavior across multiple locales; 3) performance.
4166 return label; // Match found.
4167 return NULL; // No match found.
4168}
4169
4170
4171

Callers 2

GetJumpTargetMethod · 0.80
BIF_DECLFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected