From 1e2c2fece25adad725261089ca47108937067088 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 13 Sep 2012 08:48:56 +0300 Subject: 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. --- rpmio/rpmstrpool.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'rpmio/rpmstrpool.c') diff --git a/rpmio/rpmstrpool.c b/rpmio/rpmstrpool.c index 55fc0e0bd..799136b01 100644 --- a/rpmio/rpmstrpool.c +++ b/rpmio/rpmstrpool.c @@ -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)); +} -- cgit v1.2.3