Sign in to follow this  
Lbas

Pointer access to a primiter memory area

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this