Add a note about get_item_id() being slow

This commit is contained in:
Kovid Goyal 2024-09-14 08:50:30 +05:30
parent 917f82385a
commit d5d0a97d37
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -947,7 +947,8 @@ class Cache:
@read_api @read_api
def get_item_id(self, field, item_name): def get_item_id(self, field, item_name):
' Return the item id for item_name (case-insensitive) or None if not found ' '''' Return the item id for item_name (case-insensitive) or None if not found.
This function is very slow if doing lookups for multiple names use either get_item_ids() or get_item_name_map(). '''
q = icu_lower(item_name) q = icu_lower(item_name)
try: try:
for item_id, item_val in self.fields[field].table.id_map.items(): for item_id, item_val in self.fields[field].table.id_map.items():