summaryrefslogtreecommitdiff
path: root/winaccessibility
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-11-27 00:39:13 +0100
committerMichael Stahl <mstahl@redhat.com>2013-11-28 14:37:06 +0100
commit436b39d9d1f38caeafdc9be15696ebe4162a02c8 (patch)
treeb316085603caa651731f3d200928327618fa80af /winaccessibility
parentc064e7f3b46d2e579ca4402f9cb5b7aba824fd0c (diff)
winaccessibility: improve GenerateNewResId()
Change-Id: I81f98ca83b97bc2e3e419c7a37ad2a011932553b (cherry picked from commit 0fb33f60ac08c853f14d19e6158994d092a82670)
Diffstat (limited to 'winaccessibility')
-rw-r--r--winaccessibility/inc/ResIDGenerator.hxx12
-rw-r--r--winaccessibility/source/service/ResIDGenerator.cxx20
2 files changed, 10 insertions, 22 deletions
diff --git a/winaccessibility/inc/ResIDGenerator.hxx b/winaccessibility/inc/ResIDGenerator.hxx
index f4c1f0a11791..dfe43a4f513c 100644
--- a/winaccessibility/inc/ResIDGenerator.hxx
+++ b/winaccessibility/inc/ResIDGenerator.hxx
@@ -29,28 +29,22 @@ class ResIDGenerator
{
private:
- long min;
long max;
std::deque<long> subList;
public:
- ResIDGenerator( long minNum = PRIMARY_RESID,long maxNum = PRIMARY_RESID);
+ ResIDGenerator(long maxNum = PRIMARY_RESID)
+ : max(maxNum) {}
+ ~ResIDGenerator();
long GenerateNewResID();
void SetSub(long number)
{
subList.push_back(number);
};
- virtual ~ResIDGenerator();
};
-inline ResIDGenerator::ResIDGenerator( long minNum ,long maxNum )
-{
- min = minNum;
- max = maxNum;
-}
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/winaccessibility/source/service/ResIDGenerator.cxx b/winaccessibility/source/service/ResIDGenerator.cxx
index f7da8fb208f7..8c21d9ab94b1 100644
--- a/winaccessibility/source/service/ResIDGenerator.cxx
+++ b/winaccessibility/source/service/ResIDGenerator.cxx
@@ -19,12 +19,8 @@
#include "ResIDGenerator.hxx"
-/**
- * Destructor
- *
- * @param
- * @return
- */
+#include <cassert>
+
ResIDGenerator::~ResIDGenerator()
{
}
@@ -39,15 +35,13 @@ ResIDGenerator::~ResIDGenerator()
*/
long ResIDGenerator::GenerateNewResID()
{
- if (max == LONG_MAX)
+ if (!subList.empty())
{
- if (!subList.empty())
- {
- long nRes = *(subList.begin());
- subList.pop_front();
- return nRes;
- }
+ long nRes = *(subList.begin());
+ subList.pop_front();
+ return nRes;
}
+ assert(max < LONG_MAX);
return -(++max);
}