Introduction: (not necessarily required in order to answer my question but might help)
I have a block with multiple blocks inside it (sons). For each such block (or sub-block), I am reading its DEF (design exchange format) file and assigning all its instances names to a list. So I have created a list of all instances names from all the DEF files I have read. In addition, I have a primeTime session containing all instances in the block (including the 'son' blocks).
My question:
How to efficiently search for a partial instance name inside my list?
Elaboration:
Let's say I have a list called DefInstsLst which contains thousands of instance names (read from the DEF files as described in the introduction).
For example, this list contains the following instance name:
DRO_TAP_31__ap_dro_tap/keep_dro_nr
Now, the full instance name from the top block read from primeTime is the following:
ld_top_dft_top/dro_cluster/genblk1_DRO_PACK_0__ap_dro_pack/genblk1_5__DRO_TEL_ap_dro_cell_5nm_7t_TEL/ap_dro_v2_cell/DRO_CELL_DRO_TEL_ap_dro_delay_5nm_7t_TEL/DRO_TAP_31__ap_dro_tap/keep_dro_nd
Now I want to find this instance in my list DefInstsLst according to its suffix DRO_TAP_31__ap_dro_tap/keep_dro_nd, but since it is a huge list then I have to search it efficiently (I am doing this kind of search for every instance in primeTime session).
I have tried using lsort command to sort the list and then lsearch -sorted to search efficiently but when using the flag -sorted I can't search for partial patterns but only an exact match.
When searching for instances that match exactly in their names the way I described with lsearch works perfectly in terms of run time.