int divby=128;
int foo(void) {
unsigned int i, sum=0, val=1024;
for (i=0;i<val;i++) sum+=i>>7; /* FIX: shift is same as dividing by 128, but way cheaper */
return sum;
}
int get_thingy(void); /* prototype for routine below */
inline int get_thingy(void) { /* FIX: declare subroutine *above* use, and make it "inline" */
return 2;
}
int foo(void) {
int i, sum=0, val=1024;
for (i=0;i<val;i++) sum+=get_thingy();
return sum;
}
class my_class {
public:
int val;
my_class() {val=1;}
private:
char scratch_data[0x54321];
};
int some_function(my_class &c /* FIX: pass by reference! */,int d) {
return c.val+d;
}
int foo(void) {
my_class c;
return some_function(c,0x1234+sizeof(my_class));
}
O. Lawlor, ffosl@uaf.edu
Up to: Class Site, CS, UAF