Community technical support mailing list was retired 2010 and replaced with a professional technical support team. For assistance please contact: Pre-sales Technical support via email to sales@march-hare.com.
Tony Hoyle <tmh at nodomain.org> wrote: TH> It really doesn't make a lot of difference - the time taken to setup the TH> map and copy the extra strings around offsets the advantages. The TH> common case is maybe half a dozen locks active at a time, where the TH> linear scan isn't significantly better than the lookup of a map (in the TH> general case 90% of the loop is incrementing a pointer and comparing two TH> integers. If you introduce a map it will always do string compares TH> which is slower). To optimize number of compare operations we can redefined comparision operator. /* contains upper case value for each character */ unsigned char UpperCaseTable[256]; class LockPtrLessOperator { public: bool operator()(const Lock*& left, const Lock*& right) const { if (left->length != right->length) { return left->length < right->length; } const char *path1 = left->path.c_str(); const char *path2 = right->path.c_str(); for (int i = 0; i < left->length; ++i) { if (UpperCaseTable[(int)path1[i]] < UpperCaseTable[(int)path2[i]]) { return true; } } return false; } }; map<Lock*, map<site_t,Lock*>, LockPtrLessOperator> Without string copying. Compare operations have almost the same cost as in the current implementation. This solution is more scalable for large number of concurrent users. -- Best regards, alexey-panchenko mailto:alexey-panchenko at hotmail.ru