Mailinglist Archive: yast-commit (819 mails)

< Previous Next >
[yast-commit] r54420 - /trunk/core/libycp/src/YCPBuiltinList.cc
  • From: aschnell@xxxxxxxxxxxxxxxx
  • Date: Wed, 07 Jan 2009 11:45:04 -0000
  • Message-id: <E1LKWqO-0004vF-Uc@xxxxxxxxxxxxxxxx>
Author: aschnell
Date: Wed Jan 7 12:45:04 2009
New Revision: 54420

URL: http://svn.opensuse.org/viewcvs/yast?rev=54420&view=rev
Log:
- use binary_search in setcontains

Modified:
trunk/core/libycp/src/YCPBuiltinList.cc

Modified: trunk/core/libycp/src/YCPBuiltinList.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPBuiltinList.cc?rev=54420&r1=54419&r2=54420&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPBuiltinList.cc (original)
+++ trunk/core/libycp/src/YCPBuiltinList.cc Wed Jan 7 12:45:04 2009
@@ -166,35 +166,7 @@
* @usage setcontains ([1, 2, 5], 2) -> true
*/

- if (list.isNull ())
- {
- return YCPNull ();
- }
-
- int hi = list->size () - 1;
- int lo = 0;
-
- while (lo <= hi)
- {
- int mid = (hi + lo) / 2;
- YCPValue midvalue = list->value (mid);
- YCPOrder comp = value->compare (midvalue);
-
- switch (comp)
- {
- case YO_EQUAL:
- return YCPBoolean (true);
- break;
- case YO_LESS:
- hi = mid - 1;
- break;
- case YO_GREATER:
- lo = mid + 1;
- break;
- }
- }
-
- return YCPBoolean (false);
+ return YCPBoolean(binary_search(list->begin(), list->end(), value,
ycpless()));
}



--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages