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

Method __ToObject

src/String.cpp:2550–2579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2548} // end namespace hx
2549
2550hx::Object *String::__ToObject() const
2551{
2552 if (!__s)
2553 return 0;
2554
2555 if (length==0)
2556 {
2557 return sConstEmptyString.mPtr;
2558 }
2559 else if (length==1)
2560 {
2561 #ifdef HX_SMART_STRINGS
2562 int idx = isUTF16Encoded() ? __w[0] : ((unsigned char *)__s)[0];
2563 #else
2564 int idx = ((unsigned char *)__s)[0];
2565 #endif
2566
2567 if (idx<=255)
2568 {
2569 if (sConstDynamicStrings[idx].mPtr)
2570 return sConstDynamicStrings[idx].mPtr;
2571
2572 return sConstDynamicStrings[idx].mPtr = new (hx::NewObjConst)StringData(fromCharCode(idx));
2573 }
2574 }
2575
2576 bool isConst = __s[HX_GC_CONST_ALLOC_MARK_OFFSET] & HX_GC_CONST_ALLOC_MARK_BIT;
2577 NewObjectType type = isConst ? NewObjAlloc : NewObjContainer;
2578 return new (type) StringData(*this);
2579}
2580
2581hx::Object * String::makePermanentObject() const
2582{

Callers 1

DynamicMethod · 0.80

Calls 1

isUTF16EncodedFunction · 0.85

Tested by

no test coverage detected