.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...
Posts | ||
---|---|---|
qc++ avoid pointless code | Locked | |
Thread Options | ||
|
Dec 22 2014 Anchor | |
So I'm finally recoding v106 quake-c. Notes about avoiding pointless code: void() make_bubbles = bubble = spawn(); I commented the last 3 statements out - why? When you get an entity pointer back from spawn() - You dont need to make any of these assignments immediately after calling spawn(). Entity field variables are those assigned: SOLID_NOT = 0, btw. This is also redundant: void() somefn = //return; // no point to this - it sucks up quake-c resources and does nothing Pointless code 2: other = find (world, classname, "player"); "other != world" is pointless - you can simply use: while (other) // != world) For any entity test condition, the world is entity 0. Thus (other) is always true when other is not world. This results in the same logic and saves statements and space. Logic test results for 0, '0 0 0', "", world and function zero case comparison: --- logic tests - float: 0 if (f) false if (! f) true if (f != 0) false if (f == 0) true This enumerates all logic test 0 cases. The test clearly demonstrates: With the exception of having _no_ zero case for function calls. You can only test against existing functions. Note: this logical equivalence only works when the zero test case is specified. Other values, and <=, >= tests will not use this logic. Followup: It has come to my attention that the fteqcc optimizer option -O{option,1,2,3} may possibly Un-needed code can still be left out as it uses resources. I have also realized that my quest against code bloat is likely best applied to complex code and The best advice I can give: enjoy your code. Edited by: numbersix |
Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.