• Advertisement
Sign in to follow this  

Pointer access to a primiter memory area

This topic is 4247 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I would like to be able writing something like this in my scipts : uint8* p = GetDataPtr(); for( ...; ... ;... ) { uint n = *p; p++; } I know that pointer are (still :)) not allowed, but is there any other way (using references or such) to do that without registering complex object ? The reason here is for performance issue : accessing buffer using some GetData( nIdx ) registered method is very very slower than getting a pointer on it and walk through datas (while it's not safe:)), so parsing huge amount of datas (like image processing :)) is a big issue. Thanks in advance, Lbas

Share this post


Link to post
Share on other sites
Advertisement
Until AngelScript supports true pointers, the fastest you can get is probably something like this:


// AngelScript
int p = GetDataPtr();

for( ...;...;... )
{
uint n = GetRef(p);
p++;
}


Where GetRef() is:


// C++
char *GetRef(char *p)
{
return p;
}
engine->RegisterGlobalFunction("uint8 &GetRef(int)", asFUNCTION(GetRef), asCALL_CDECL);

Share this post


Link to post
Share on other sites
Thanks WitchLord,
It works fine and it's an alternative to write more optimized algorithms, we would just have to replace all 'GetRef(p)' with '*p' when it will be available.
Thanks a lot,
Lbas

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement