Lets make sure, shall we
-
Doing some code clean up and found this gem
if ( flag && test_fn() )
{
if ( test_fn() )
{
/* do domething */
}
}test_fn() isn't particularly expensive ... but really?
So presumably
test_fn
looks something like this:private int _testCallCount = 0;
public bool test_fn()
{
_testCallCount++;
return (_testCallCount & 1) == 0;
}:)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Doing some code clean up and found this gem
if ( flag && test_fn() )
{
if ( test_fn() )
{
/* do domething */
}
}test_fn() isn't particularly expensive ... but really?
-
Doing some code clean up and found this gem
if ( flag && test_fn() )
{
if ( test_fn() )
{
/* do domething */
}
}test_fn() isn't particularly expensive ... but really?
What if test_fn() does change a global such that, when the next time it runs, may not return true? That makes perfect sense to call a function after already calling validating it. I've set a flag that, when true, also calls a function within an If statement. I once-again call the function to see if we're still good to go, especially in a parallel processing app that can change datapoints before another process gets to it. I then recursion into the function during the function to ensure that no externals have changed while it is in process, for it calls additional functions. And, if you believe I do all this, then hire me at $1 million a year and I'll gladly implement this into yer project!
-
What if test_fn() does change a global such that, when the next time it runs, may not return true? That makes perfect sense to call a function after already calling validating it. I've set a flag that, when true, also calls a function within an If statement. I once-again call the function to see if we're still good to go, especially in a parallel processing app that can change datapoints before another process gets to it. I then recursion into the function during the function to ensure that no externals have changed while it is in process, for it calls additional functions. And, if you believe I do all this, then hire me at $1 million a year and I'll gladly implement this into yer project!
MacSpudster wrote:
I once-again call the function to see if we're still good to go
You really should be using locking :P
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
----------------------------------------------- 128 bit encrypted signature, crack if you can
-
MacSpudster wrote:
I once-again call the function to see if we're still good to go
You really should be using locking :P
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
----------------------------------------------- 128 bit encrypted signature, crack if you can
-
Doing some code clean up and found this gem
if ( flag && test_fn() )
{
if ( test_fn() )
{
/* do domething */
}
}test_fn() isn't particularly expensive ... but really?
May be this poor guy think that check test_fn() 1 time is not True enough, and he do it twice just for sure :-\
In code we trust !