Kaydet (Commit) 0fb33f60 authored tarafından Michael Stahl's avatar Michael Stahl

winaccessibility: improve GenerateNewResId()

Change-Id: I81f98ca83b97bc2e3e419c7a37ad2a011932553b
üst e094d6fa
...@@ -29,28 +29,22 @@ class ResIDGenerator ...@@ -29,28 +29,22 @@ class ResIDGenerator
{ {
private: private:
long min;
long max; long max;
std::deque<long> subList; std::deque<long> subList;
public: public:
ResIDGenerator( long minNum = PRIMARY_RESID,long maxNum = PRIMARY_RESID); ResIDGenerator(long maxNum = PRIMARY_RESID)
: max(maxNum) {}
~ResIDGenerator();
long GenerateNewResID(); long GenerateNewResID();
void SetSub(long number) void SetSub(long number)
{ {
subList.push_back(number); subList.push_back(number);
}; };
virtual ~ResIDGenerator();
}; };
inline ResIDGenerator::ResIDGenerator( long minNum ,long maxNum )
{
min = minNum;
max = maxNum;
}
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -19,12 +19,8 @@ ...@@ -19,12 +19,8 @@
#include "ResIDGenerator.hxx" #include "ResIDGenerator.hxx"
/** #include <cassert>
* Destructor
*
* @param
* @return
*/
ResIDGenerator::~ResIDGenerator() ResIDGenerator::~ResIDGenerator()
{ {
} }
...@@ -39,15 +35,13 @@ ResIDGenerator::~ResIDGenerator() ...@@ -39,15 +35,13 @@ ResIDGenerator::~ResIDGenerator()
*/ */
long ResIDGenerator::GenerateNewResID() long ResIDGenerator::GenerateNewResID()
{ {
if (max == LONG_MAX) if (!subList.empty())
{ {
if (!subList.empty()) long nRes = *(subList.begin());
{ subList.pop_front();
long nRes = *(subList.begin()); return nRes;
subList.pop_front();
return nRes;
}
} }
assert(max < LONG_MAX);
return -(++max); return -(++max);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment