| 2548 | } // end namespace hx |
| 2549 | |
| 2550 | hx::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 | |
| 2581 | hx::Object * String::makePermanentObject() const |
| 2582 | { |
no test coverage detected