Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4594b3a

Browse files
committed
Fix fastCodeAt on cppia for HaxeFoundation/haxe#7506
1 parent 4a252e8 commit 4594b3a

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/hx/cppia/StringBuiltin.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ struct CharAtExpr : public StringExpr
154154
BCR_CHECK;
155155

156156
if (AS_INT)
157-
return (int)( ((unsigned char *)val.__s) [idx]);
157+
return (int)val.cca(idx);
158158
else
159159
return val.charCodeAt(idx);
160160
}
@@ -168,7 +168,7 @@ struct CharAtExpr : public StringExpr
168168
if (CODE)
169169
{
170170
if (AS_INT)
171-
return Dynamic( (int)( ((unsigned char *)val.__s) [idx]) ).mPtr;
171+
return Dynamic( val.cca(idx) ).mPtr;
172172
else
173173
return val.charCodeAt(idx).mPtr;
174174
}
@@ -181,6 +181,10 @@ struct CharAtExpr : public StringExpr
181181
{
182182
return (inValue->charCodeAt(inIndex)).mPtr;
183183
}
184+
static int SLJIT_CALL runCca(String *inValue, int inIndex)
185+
{
186+
return (inValue->cca(inIndex));
187+
}
184188
static void SLJIT_CALL runCharAt(String *ioValue, int inIndex)
185189
{
186190
*ioValue = ioValue->charAt(inIndex);
@@ -196,6 +200,10 @@ struct CharAtExpr : public StringExpr
196200
{
197201
if (AS_INT)
198202
{
203+
#ifdef HX_SMART_STRINGS
204+
compiler->callNative( (void *)runCca, value, sJitTemp1.as(jtInt));
205+
compiler->convertReturnReg( etInt, inDest, destType);
206+
#else
199207
// sJitTemp1 = __s
200208
compiler->move( sJitTemp0.as(jtPointer), value.star(jtPointer,offsetof(String,__s)) );
201209
if (destType==etInt)
@@ -207,6 +215,7 @@ struct CharAtExpr : public StringExpr
207215
compiler->move(sJitTemp0.as(jtInt), sJitTemp0.atReg(sJitTemp1,0,jtByte) );
208216
compiler->convertReturnReg(etInt, inDest, destType);
209217
}
218+
#endif
210219
}
211220
else
212221
{

0 commit comments

Comments
 (0)