MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / __string_hash_map_substr

Function __string_hash_map_substr

src/hx/Hash.cpp:737–799  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

735}
736
737::String __string_hash_map_substr(HX_MAP_THIS_ARG,String inKey, int inStart, int inLength)
738{
739 StringHashBase *sash = static_cast<StringHashBase *>(ioHash.GetPtr());
740 if (!sash)
741 {
742 sash = new StringHashInt();
743 ioHash = sash;
744 HX_OBJ_WB_GET(owner,sash);
745 }
746 else if (sash->store!=hashInt)
747 {
748 sash = sash->convertStore(hashInt);
749 ioHash = sash;
750 HX_OBJ_WB_GET(owner,sash);
751 }
752
753 StringHashInt *shi = static_cast<StringHashInt *>(sash);
754
755
756 struct Finder
757 {
758 ::String bigString;
759 int len;
760 int offset;
761
762 Finder(const String &inBigStr, int inStart, int inLength) : bigString(inBigStr), offset(inStart), len(inLength) { }
763
764 bool operator==(const String &inKey) const
765 {
766 if (inKey.length!=len)
767 return false;
768 #ifdef HX_SMART_STRINGS
769 if (inKey.isUTF16Encoded())
770 {
771 // Has no wide chars, so can't match
772 if (!bigString.isUTF16Encoded())
773 return false;
774 return !memcmp(inKey.__w, bigString.__w+offset, sizeof(char16_t)*len);
775 }
776 else if (bigString.isUTF16Encoded())
777 {
778 const char *k = inKey.__s;
779 const char16_t *v = bigString.__w + offset;
780 for(int i=0;i<len;i++)
781 if (k[i] != v[i])
782 return false;
783 return true;
784 }
785 // fallthough...
786 #endif
787 return !memcmp(inKey.__s, bigString.__s+offset, len);
788 }
789 };
790 Finder finder(inKey, inStart, inLength);
791
792 unsigned int code = inKey.calcSubHash(inStart,inLength);
793 String found;
794 if (shi->findEquivalentKey(found,code,finder))

Callers

nothing calls this directly

Calls 6

GetPtrMethod · 0.80
convertStoreMethod · 0.80
calcSubHashMethod · 0.80
findEquivalentKeyMethod · 0.80
substrMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected