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

Method substr

src/String.cpp:2113–2144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2111
2112
2113String String::substr(int inFirst, Dynamic inLen) const
2114{
2115 int len = inLen == null() ? length : inLen->__ToInt();
2116 if (inFirst<0) inFirst += length;
2117 if (inFirst<0) inFirst = 0;
2118 if (len<0)
2119 {
2120 len = length + len - inFirst;
2121 }
2122
2123 if (len<=0 || inFirst>=length)
2124 return String::emptyString;
2125
2126 if ((len+inFirst > length) ) len = length - inFirst;
2127 if (len==0)
2128 return String::emptyString;
2129
2130
2131 #ifdef HX_SMART_STRINGS
2132 if (isUTF16Encoded())
2133 {
2134 if (len==1)
2135 return String::fromCharCode(__w[inFirst]);
2136 return String( GCStringDup(__w+inFirst, len, 0), len );
2137 }
2138 #endif
2139
2140 if (len==1)
2141 return String::fromCharCode(__s[inFirst]);
2142
2143 return String( GCStringDup(__s+inFirst, len, 0), len );
2144}
2145
2146String String::substring(int startIndex, Dynamic inEndIndex) const
2147{

Callers 7

_hx_utf8_subFunction · 0.80
__string_hash_map_substrFunction · 0.80
FindHaxelibFunction · 0.80
linkMethod · 0.80
runStringMethod · 0.80
runSubstrMethod · 0.80
_hx_regexp_matchedFunction · 0.80

Calls 5

isUTF16EncodedFunction · 0.85
GCStringDupFunction · 0.85
nullClass · 0.50
StringClass · 0.50
__ToIntMethod · 0.45

Tested by

no test coverage detected