ProfDrBielefeld
Inactive Member-
Posts
4 -
Joined
-
Last visited
-
Feedback
0%
About ProfDrBielefeld
Informations
-
Gender
Male
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
ProfDrBielefeld's Achievements
-
struct FPartyHasItem { DWORD itemid; bool allhaveitem; void operator () (LPCHARACTER ch) { if(!ch) { return; } if(!(ch->CountSpecifyItem(itemid) > 0)) { allhaveitem = false; } } }; int party_check_item(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); FPartyHasItem f; if (!lua_isnumber(L, 1)) { lua_pushboolean (L, false); return 1; } else { f.itemid = lua_tonumber(L, 1); } f.allhaveitem = true; ch->GetParty()->ForEachMemberPtr(f); lua_pushboolean (L, f.allhaveitem); return 1; } This is my function for checking all member.
-
Guys.. pls.. There is no performance difference between it++ and ++it. i++ could potentially be slower than ++i, since the old value of i might need to be saved for later use, but in practice all modern compilers will optimize this away. I can demonstrate this by looking at the code for this function, both with ++i and i++. $ cat i++.c extern void g(int i); void f() { int i; for (i = 0; i < 100; i++) g(i); } The files are the same, except for ++i and i++: $ diff i++.c ++i.c 6c6 < for (i = 0; i < 100; i++) --- > for (i = 0; i < 100; ++i) I 'll compile them, and also get the generated assembler: So after this we can see that both the generated object and assembler files are the same. $ md5 i++.s ++i.s MD5 (i++.s) = 90f620dda862cd0205cd5db1f2c8c06e MD5 (++i.s) = 90f620dda862cd0205cd5db1f2c8c06e $ md5 *.o MD5 (++i.o) = dd3ef1408d3a9e4287facccec53f7d22 MD5 (i++.o) = dd3ef1408d3a9e4287facccec53f7d22 This means, that after compiling both codes are the same. Both have the same runtime. Well, I hope that helps. Best regards , ProfDrBielefeld