From: Panu Matilainen Date: Thu, 13 Sep 2012 05:48:56 +0000 (+0300) Subject: Add a string equality check function to string pool API X-Git-Tag: tznext/4.11.0.1.tizen20130304~284 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e2c2fece25adad725261089ca47108937067088;p=tools%2Flibrpm-tizen.git 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. --- diff --git a/rpmio/rpmstrpool.c b/rpmio/rpmstrpool.c index 55fc0e0..799136b 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)); +} diff --git a/rpmio/rpmstrpool.h b/rpmio/rpmstrpool.h index 67e1620..5794032 100644 --- a/rpmio/rpmstrpool.h +++ b/rpmio/rpmstrpool.h @@ -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