Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast type lookup #6241

Open
wants to merge 6 commits into
base: 1.4
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor(core): Use the full NodeId for the type lookup
  • Loading branch information
jpfr committed Jan 22, 2024
commit dc8d47448cf121055e986515c2c59f4a10804fcd
23 changes: 11 additions & 12 deletions src/ua_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,17 @@ UA_findDataTypeWithCustom(const UA_NodeId *typeId,
/* Always look in UA_TYPES first. UA_TYPES is ordered and contains only
* types from ns0 with a numeric identifier. So we can use binary search to
* speed this up. */
if(typeId->namespaceIndex == 0 && typeId->identifierType == UA_NODEIDTYPE_NUMERIC) {
size_t first = 0;
size_t last = UA_TYPES_COUNT - 1;
while(first <= last) {
size_t middle = (first+last) >> 1;
if(UA_TYPES[middle].typeId.identifier.numeric == typeId->identifier.numeric)
return &UA_TYPES[middle];
if(UA_TYPES[middle].typeId.identifier.numeric < typeId->identifier.numeric)
first = middle + 1;
else
last = middle - 1;
}
size_t first = 0;
size_t last = UA_TYPES_COUNT - 1;
while(first <= last) {
size_t middle = (first+last) >> 1;
UA_Order cmp = UA_NodeId_order(&UA_TYPES[middle].typeId, typeId);
if(cmp == UA_ORDER_EQ)
return &UA_TYPES[middle];
if(cmp == UA_ORDER_LESS)
first = middle + 1;
else
last = middle - 1;
}

/* Search in the customTypes */
Expand Down
Loading