mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 02:03:04 +01:00
Cleanup - avoid unneeded generate's argument in SortedArray and Hash
This commit is contained in:
parent
87389723d6
commit
18d66a33b4
@ -201,7 +201,7 @@ namespace Firebird
|
||||
public:
|
||||
bool add(C* value)
|
||||
{
|
||||
Entry** e = locate(KeyOfValue::generate(this, *value));
|
||||
Entry** e = locate(KeyOfValue::generate(*value));
|
||||
if (*e)
|
||||
{
|
||||
return false; // sorry, duplicate
|
||||
|
@ -498,14 +498,14 @@ public:
|
||||
while (highBound > lowBound)
|
||||
{
|
||||
const size_t temp = (highBound + lowBound) >> 1;
|
||||
if (Cmp::greaterThan(item, KeyOfValue::generate(this, this->data[temp])))
|
||||
if (Cmp::greaterThan(item, KeyOfValue::generate(this->data[temp])))
|
||||
lowBound = temp + 1;
|
||||
else
|
||||
highBound = temp;
|
||||
}
|
||||
pos = lowBound;
|
||||
return highBound != this->count &&
|
||||
!Cmp::greaterThan(KeyOfValue::generate(this, this->data[lowBound]), item);
|
||||
!Cmp::greaterThan(KeyOfValue::generate(this->data[lowBound]), item);
|
||||
}
|
||||
|
||||
bool exist(const Key& item) const
|
||||
@ -518,7 +518,7 @@ public:
|
||||
{
|
||||
size_t pos;
|
||||
if (sortMode == FB_ARRAY_SORT_WHEN_ADD)
|
||||
find(KeyOfValue::generate(this, item), pos);
|
||||
find(KeyOfValue::generate(item), pos);
|
||||
else
|
||||
{
|
||||
sorted = false;
|
||||
@ -542,7 +542,7 @@ public:
|
||||
if (sorted)
|
||||
return;
|
||||
|
||||
qsort(this->begin(), this->getCount(), sizeof(Value), compar);
|
||||
qsort(this->begin(), this->getCount(), sizeof(Value), compare);
|
||||
sorted = true;
|
||||
}
|
||||
|
||||
@ -550,17 +550,10 @@ private:
|
||||
int sortMode;
|
||||
bool sorted;
|
||||
|
||||
static int compar(const void* a, const void* b)
|
||||
static int compare(const void* a, const void* b)
|
||||
{
|
||||
// Calling generate() with NULL argument looks dangerous and wrong.
|
||||
// Correct solution is to use qsort_s/qsort_r functions instead qsort.
|
||||
// But in our sources the only place using 'sender' in generate() is BPlusTree
|
||||
// and not with SortedArray but with SortedVector. Using qsort_r/s is overhead for us.
|
||||
// As an additional disaster there are 2 incompatible (BSD/glibc) clones of qsort_r.
|
||||
// It's also possible to change SortedArray API without loosing functionality.
|
||||
// I suppose we can do a choice a bit later. AP-2013.
|
||||
const Key& first(KeyOfValue::generate(NULL, *reinterpret_cast<const Value*>(a)));
|
||||
const Key& second(KeyOfValue::generate(NULL, *reinterpret_cast<const Value*>(b)));
|
||||
const Key& first(KeyOfValue::generate(*reinterpret_cast<const Value*>(a)));
|
||||
const Key& second(KeyOfValue::generate(*reinterpret_cast<const Value*>(b)));
|
||||
|
||||
if (Cmp::greaterThan(first, second))
|
||||
return 1;
|
||||
|
@ -149,6 +149,10 @@ template <typename P>
|
||||
{
|
||||
public:
|
||||
typedef typename P::first_type Pair_first_type;
|
||||
static const Pair_first_type& generate(const P& item)
|
||||
{
|
||||
return item.first;
|
||||
}
|
||||
static const Pair_first_type& generate(const void* /*sender*/, const P& item)
|
||||
{
|
||||
return item.first;
|
||||
@ -160,6 +164,10 @@ template <typename P>
|
||||
{
|
||||
public:
|
||||
typedef typename P::first_type Pair_first_type;
|
||||
static const Pair_first_type* generate(const P* item)
|
||||
{
|
||||
return &item->first;
|
||||
}
|
||||
static const Pair_first_type* generate(const void* /*sender*/, const P* item)
|
||||
{
|
||||
return &item->first;
|
||||
@ -171,6 +179,10 @@ template <typename P>
|
||||
{
|
||||
public:
|
||||
typedef typename P::first_type Pair_first_type;
|
||||
static const Pair_first_type& generate(const P* item)
|
||||
{
|
||||
return item->first;
|
||||
}
|
||||
static const Pair_first_type& generate(const void* /*sender*/, const P* item)
|
||||
{
|
||||
return item->first;
|
||||
|
@ -360,7 +360,7 @@ namespace Firebird
|
||||
class ObjectKeyValue
|
||||
{
|
||||
public:
|
||||
static const T& generate(const void* /*sender*/, const T* item) { return item; }
|
||||
static const T& generate(const T* item) { return item; }
|
||||
};
|
||||
|
||||
// Template for default value comparator
|
||||
|
@ -140,6 +140,7 @@ class DefaultKeyValue
|
||||
{
|
||||
public:
|
||||
static const T& generate(const void* /*sender*/, const T& item) { return item; }
|
||||
static const T& generate(const T& item) { return item; }
|
||||
};
|
||||
|
||||
// Fast sorted array of simple objects
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
Firebird::RefPtr<ConfigFile> sub;
|
||||
unsigned int line;
|
||||
|
||||
static const KeyType* generate(const void* /*sender*/, const Parameter* item)
|
||||
static const KeyType* generate(const Parameter* item)
|
||||
{
|
||||
return &item->name;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace
|
||||
template <typename T>
|
||||
struct PathHash
|
||||
{
|
||||
static const PathName& generate(const void* /*sender*/, const T& item)
|
||||
static const PathName& generate(const T& item)
|
||||
{
|
||||
return item.name;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
ULONG mbs_src_line;
|
||||
ULONG mbs_src_col;
|
||||
|
||||
static ULONG generate(const void*, const MapBlrToSrcItem& Item)
|
||||
static ULONG generate(const MapBlrToSrcItem& Item)
|
||||
{ return Item.mbs_offset; }
|
||||
};
|
||||
|
||||
|
@ -77,7 +77,7 @@ private:
|
||||
return m_relID;
|
||||
}
|
||||
|
||||
static inline const USHORT generate(void const*, const RelationData* item)
|
||||
static inline const USHORT generate(const RelationData* item)
|
||||
{
|
||||
return item->m_relID;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
static USHORT generate(const void*, const ViewContext* vc)
|
||||
static USHORT generate(const ViewContext* vc)
|
||||
{
|
||||
return vc->vcx_context;
|
||||
}
|
||||
@ -97,7 +97,7 @@ public:
|
||||
|
||||
void free(RelationPages*& nextFree);
|
||||
|
||||
static inline ULONG generate(const void*, const RelationPages* item)
|
||||
static inline ULONG generate(const RelationPages* item)
|
||||
{
|
||||
return item->rel_instance_id;
|
||||
}
|
||||
|
@ -64,12 +64,12 @@ struct RelationCounts
|
||||
SINT64 rlc_counter[DBB_max_count];
|
||||
|
||||
#ifdef REL_COUNTS_PTR
|
||||
inline static const SLONG* generate(const void* /*sender*/, const RelationCounts* item)
|
||||
inline static const SLONG* generate(const RelationCounts* item)
|
||||
{
|
||||
return &item->rlc_relation_id;
|
||||
}
|
||||
#else
|
||||
inline static const SLONG& generate(const void* /*sender*/, const RelationCounts& item)
|
||||
inline static const SLONG& generate(const RelationCounts& item)
|
||||
{
|
||||
return item.rlc_relation_id;
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ public:
|
||||
|
||||
DfwSavePoint* get() { return this; }
|
||||
|
||||
static SLONG generate(const void* /*sender*/, const DfwSavePoint& item)
|
||||
static SLONG generate(const DfwSavePoint& item)
|
||||
{
|
||||
return item.dfw_sav_number;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
// Interprete status and put error description into passed string
|
||||
virtual void getRemoteError(const ISC_STATUS* status, Firebird::string& err) const = 0;
|
||||
|
||||
static const Firebird::string* generate(const void*, const Provider* item)
|
||||
static const Firebird::string* generate(const Provider* item)
|
||||
{
|
||||
return &item->m_name;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ struct LocksArrayItem {
|
||||
|
||||
LocksArrayItem() {}
|
||||
LocksArrayItem(HANDLE handle, Firebird::Mutex* mutex) : first(handle), second(mutex) { }
|
||||
static HANDLE generate(const void*, LocksArrayItem value) {
|
||||
static HANDLE generate(LocksArrayItem value) {
|
||||
return value.first;
|
||||
}
|
||||
};
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
return (pageSpaceID >= TEMP_PAGE_SPACE);
|
||||
}
|
||||
|
||||
static inline SLONG generate(const void* , const PageSpace* Item)
|
||||
static inline SLONG generate(const PageSpace* Item)
|
||||
{
|
||||
return Item->pageSpaceID;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
i1.level > i2.level;
|
||||
}
|
||||
|
||||
static inline const traRpbListElement& generate(const void* /*sender*/, const traRpbListElement& item)
|
||||
static inline const traRpbListElement& generate(const traRpbListElement& item)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ namespace
|
||||
explicit RunSort(run_control* irun) : run(irun) {}
|
||||
RunSort() : run(NULL) {}
|
||||
|
||||
static FB_UINT64 generate(const void*, const RunSort& item)
|
||||
static FB_UINT64 generate(const RunSort& item)
|
||||
{
|
||||
return item.run->run_seek;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
TraNumber tpc_base; // id of first transaction in this block
|
||||
UCHAR tpc_transactions[1]; // two bits per transaction
|
||||
|
||||
static const TraNumber generate(const void*, const TxPage* item)
|
||||
static const TraNumber generate(const TxPage* item)
|
||||
{
|
||||
return item->tpc_base;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ private:
|
||||
TracePlugin* plugin;
|
||||
ULONG ses_id;
|
||||
|
||||
static ULONG generate(const void*, const SessionInfo& item)
|
||||
static ULONG generate(const SessionInfo& item)
|
||||
{ return item.ses_id; }
|
||||
};
|
||||
class Sessions : public Firebird::SortedArray<SessionInfo, Firebird::EmptyStorage<SessionInfo>, ULONG, SessionInfo>
|
||||
|
@ -124,7 +124,7 @@ public:
|
||||
: login(p, fl.login), failCount(fl.failCount), lastAttempt(fl.lastAttempt)
|
||||
{}
|
||||
|
||||
static const string* generate(const void*, const FailedLogin* f)
|
||||
static const string* generate(const FailedLogin* f)
|
||||
{
|
||||
return &f->login;
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ struct TimerEntry
|
||||
TimerDelay fireTime;
|
||||
ITimer* timer;
|
||||
|
||||
static const TimerDelay generate(const void* /*sender*/, const TimerEntry& item) { return item.fireTime; }
|
||||
static const TimerDelay generate(const TimerEntry& item) { return item.fireTime; }
|
||||
static THREAD_ENTRY_DECLARE timeThread(THREAD_ENTRY_PARAM);
|
||||
|
||||
static void init()
|
||||
|
Loading…
Reference in New Issue
Block a user