Skip to content

Commit 23ab71d

Browse files
committed
improved:select mode code
1 parent f16b743 commit 23ab71d

File tree

2 files changed

+8
-64
lines changed

2 files changed

+8
-64
lines changed

XEngine_Source/StorageModule_APIHelp/APIHelp_Distributed/APIHelp_Distributed.cpp

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
*********************************************************************/
1414
CAPIHelp_Distributed::CAPIHelp_Distributed()
1515
{
16-
nRandomFront = 0;
17-
nRandomBack = 0;
18-
nUPFront = 0;
19-
nUPBack = 0;
2016
}
2117
CAPIHelp_Distributed::~CAPIHelp_Distributed()
2218
{
@@ -81,37 +77,13 @@ bool CAPIHelp_Distributed::APIHelp_Distributed_RandomAddr(list<string>* pStl_Lis
8177
}
8278
else if (2 == nMode)
8379
{
84-
if (nRandomFront >= pStl_ListAddr->size())
85-
{
86-
nRandomFront = 0;
87-
}
88-
unsigned int i = 0;
89-
for (auto stl_ListIterator = pStl_ListAddr->begin(); stl_ListIterator != pStl_ListAddr->end(); stl_ListIterator++, i++)
90-
{
91-
if (nRandomFront == i)
92-
{
93-
bFound = true;
94-
_tcsxcpy(ptszAddr, stl_ListIterator->c_str());
95-
break;
96-
}
97-
}
80+
bFound = true;
81+
_tcsxcpy(ptszAddr, pStl_ListAddr->front().c_str());
9882
}
9983
else if (3 == nMode)
10084
{
101-
if (nRandomBack >= pStl_ListAddr->size())
102-
{
103-
nRandomBack = 0;
104-
}
105-
unsigned int i = 0;
106-
for (auto stl_ListIterator = pStl_ListAddr->rbegin(); stl_ListIterator != pStl_ListAddr->rend(); stl_ListIterator++, i++)
107-
{
108-
if (nRandomBack == i)
109-
{
110-
bFound = true;
111-
_tcsxcpy(ptszAddr, stl_ListIterator->c_str());
112-
break;
113-
}
114-
}
85+
bFound = true;
86+
_tcsxcpy(ptszAddr, pStl_ListAddr->back().c_str());
11587
}
11688

11789
if (!bFound)
@@ -377,37 +349,13 @@ bool CAPIHelp_Distributed::APIHelp_Distributed_UPStorage(list<XENGINE_STORAGEBUC
377349
}
378350
else if (2 == nMode)
379351
{
380-
if (nUPFront >= stl_BuckSelect.size())
381-
{
382-
nUPFront = 0;
383-
}
384-
unsigned int i = 0;
385-
for (auto stl_ListIterator = stl_BuckSelect.begin(); stl_ListIterator != stl_BuckSelect.end(); stl_ListIterator++, i++)
386-
{
387-
if (nUPFront == i)
388-
{
389-
bFound = true;
390-
*pSt_StorageBucket = *stl_ListIterator;
391-
break;
392-
}
393-
}
352+
bFound = true;
353+
*pSt_StorageBucket = stl_BuckSelect.front();
394354
}
395355
else if (3 == nMode)
396356
{
397-
if (nUPBack >= stl_BuckSelect.size())
398-
{
399-
nUPBack = 0;
400-
}
401-
unsigned int i = 0;
402-
for (auto stl_ListIterator = stl_BuckSelect.rbegin(); stl_ListIterator != stl_BuckSelect.rend(); stl_ListIterator++, i++)
403-
{
404-
if (nUPBack == i)
405-
{
406-
bFound = true;
407-
*pSt_StorageBucket = *stl_ListIterator;
408-
break;
409-
}
410-
}
357+
bFound = true;
358+
*pSt_StorageBucket = stl_BuckSelect.back();
411359
}
412360

413361
if (!bFound)

XEngine_Source/StorageModule_APIHelp/APIHelp_Distributed/APIHelp_Distributed.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,4 @@ class CAPIHelp_Distributed
2727
bool APIHelp_Distributed_FileListParse(LPCXSTR lpszMsgBuffer, int nMsgLen, XSTORAGECORE_DBFILE* pSt_DBFile);
2828
__int64u APIHelp_Distributed_GetSize(LPCXSTR lpszMsgBuffer);
2929
private:
30-
unsigned int nRandomFront;
31-
unsigned int nRandomBack;
32-
unsigned int nUPFront;
33-
unsigned int nUPBack;
3430
};

0 commit comments

Comments
 (0)