A
Allan Bruce
Hi there,
I am loading in a 3d object from file. The code I have works fine but it is
very slow for objects with many vertices, i.e. >5000
I make use of the atoi function 3 times for each vertex, so am making a lot
of them! I wish to make a macro to speed up execution. I know that the
numbers will all be stored correctly in a char array in memory. I also know
that each number will be >0 and I will limit the value to less then the max
value of UINT on my machine.
I have made macros before, but very simple ones. I want to make a macro for
the above definition. My (poor) attempt is below. I know I am well off as
far as macros go, but does anyone have any suggestions as to how I should
proceed?
Many Thanks
Allan
#define ATOI(X) ( temp = 0; \
while(1){ \
if ((*X >='0') && (*X <='9')) \
{ \
temp*=10; \
temp += *X -'0'; \
X++; \
} \
else \
{ \
X++; \
break; \
} \
} \
temp)
I am loading in a 3d object from file. The code I have works fine but it is
very slow for objects with many vertices, i.e. >5000
I make use of the atoi function 3 times for each vertex, so am making a lot
of them! I wish to make a macro to speed up execution. I know that the
numbers will all be stored correctly in a char array in memory. I also know
that each number will be >0 and I will limit the value to less then the max
value of UINT on my machine.
I have made macros before, but very simple ones. I want to make a macro for
the above definition. My (poor) attempt is below. I know I am well off as
far as macros go, but does anyone have any suggestions as to how I should
proceed?
Many Thanks
Allan
#define ATOI(X) ( temp = 0; \
while(1){ \
if ((*X >='0') && (*X <='9')) \
{ \
temp*=10; \
temp += *X -'0'; \
X++; \
} \
else \
{ \
X++; \
break; \
} \
} \
temp)