Add a string equality check function to string pool API
- As a special case, two strings (ids) from the same pool can be tested for equality in constant time (integer comparison). If the pools differ, a regular string comparison is needed.
This commit is contained in:
parent
b6c794362a
commit
1e2c2fece2
|
@ -173,3 +173,12 @@ size_t rpmstrPoolStrlen(rpmstrPool pool, rpmsid sid)
|
|||
}
|
||||
return slen;
|
||||
}
|
||||
|
||||
int rpmstrPoolStreq(rpmstrPool poolA, rpmsid sidA,
|
||||
rpmstrPool poolB, rpmsid sidB)
|
||||
{
|
||||
if (poolA == poolB)
|
||||
return (sidA == sidB);
|
||||
else
|
||||
return rstreq(rpmstrPoolStr(poolA, sidA), rpmstrPoolStr(poolB, sidB));
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@ const char * rpmstrPoolStr(rpmstrPool sidpool, rpmsid sid);
|
|||
/* get a strings length by its id (in constant time) */
|
||||
size_t rpmstrPoolStrlen(rpmstrPool pool, rpmsid sid);
|
||||
|
||||
/* pool string equality comparison (constant time if within same pool) */
|
||||
int rpmstrPoolStreq(rpmstrPool poolA, rpmsid sidA,
|
||||
rpmstrPool poolB, rpmsid sidB);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue