- Timestamp:
- May 30, 2001, 3:02:55 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/ccollection.cpp
r5832 r5838 1 /* $Id: ccollection.cpp,v 1. 3 2001-05-30 03:28:02phaller Exp $ */1 /* $Id: ccollection.cpp,v 1.4 2001-05-30 13:02:55 phaller Exp $ */ 2 2 3 3 /* … … 652 652 { 653 653 PHASHTABLEENTRY pHTE = (PHASHTABLEENTRY)pLLE->pObject; 654 if (strcmp(pHTE->pszName, pszName) == 0) 655 { 656 // save old object pointer 657 void* pTemp = pHTE->pObject; 658 free(pHTE); 659 660 // found the correct entry 661 parrLists[ulHash]->removeElement(pLLE); 662 663 // count allocated elements 664 iElements--; 665 666 // return old object pointer to signal success 667 return pTemp; 668 } 654 655 // quickly compare 1st character for equality 656 // before doing the strcmp call 657 if (*pHTE->pszName == *pszName) 658 if (strcmp(pHTE->pszName, pszName) == 0) 659 { 660 // save old object pointer 661 void* pTemp = pHTE->pObject; 662 free(pHTE); 663 664 // found the correct entry 665 parrLists[ulHash]->removeElement(pLLE); 666 667 // count allocated elements 668 iElements--; 669 670 // return old object pointer to signal success 671 return pTemp; 672 } 669 673 670 674 pLLE = pLLE->pNext; … … 702 706 { 703 707 PHASHTABLEENTRY pHTE = (PHASHTABLEENTRY)pLLE->pObject; 704 if (strcmp(pHTE->pszName, pszName) == 0) 705 { 706 // return result 707 return pHTE->pObject; 708 } 708 709 // quickly compare 1st character for equality 710 // before doing the strcmp call 711 if (*pHTE->pszName == *pszName) 712 if (strcmp(pHTE->pszName, pszName) == 0) 713 { 714 // return result 715 return pHTE->pObject; 716 } 709 717 710 718 pLLE = pLLE->pNext; … … 735 743 void CHashtableLookup::rehash() 736 744 { 745 // if there are less slots than elements, 746 // the blocking factor is expected to be high 747 setSize(iElements); 748 } 749 750 751 void CHashtableLookup::setSize(int iNewSize) 752 { 737 753 // determine number of allocated elements 738 754 // actually, we need the prime next to 739 755 // the given number. 740 int iNewSize = nextPrime(iElements); 741 742 setSize(iNewSize); 743 } 744 745 746 void CHashtableLookup::setSize(int iNewSize) 756 if (iSize < iNewSize) 757 setSize0(nextPrime(iNewSize)); 758 } 759 760 761 void CHashtableLookup::setSize0(int iNewSize) 747 762 { 748 763 // check if rehashing is necessary at all
Note:
See TracChangeset
for help on using the changeset viewer.