diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-11-27 00:39:13 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-11-28 00:59:53 +0100 |
commit | 0fb33f60ac08c853f14d19e6158994d092a82670 (patch) | |
tree | 387b11b27733d059092377d806fa3af15cbc7c0c /winaccessibility | |
parent | winaccessibility: remove GetXAccByAccObj() (diff) | |
download | core-0fb33f60ac08c853f14d19e6158994d092a82670.tar.gz core-0fb33f60ac08c853f14d19e6158994d092a82670.zip |
winaccessibility: improve GenerateNewResId()
Change-Id: I81f98ca83b97bc2e3e419c7a37ad2a011932553b
Diffstat (limited to 'winaccessibility')
-rw-r--r-- | winaccessibility/inc/ResIDGenerator.hxx | 12 | ||||
-rw-r--r-- | winaccessibility/source/service/ResIDGenerator.cxx | 20 |
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); } |