performance issues of calling a function in if condition


 
Thread Tools Search this Thread
Top Forums Programming performance issues of calling a function in if condition
# 1  
Old 04-04-2010
Question performance issues of calling a function in if condition

Hi,

I have written a program in C and have to test the return value of the functions. So the normal way of doin this wud b

Code:
int rc
rc=myfunction(input);
if(rc=TRUE){
 
}
else{
}

But instead of doing this I have called the function in the if() condition. Does this have any impilcations on the performance

What I have done is

Code:
if(myfunction(input)== TRUE){
 
}
 
else{
 
}

regards
Sid

Last edited by Franklin52; 04-04-2010 at 09:07 AM.. Reason: Please use code tags!
# 2  
Old 04-04-2010
The second way should be more efficient. Or even:
Code:
if(myfunction(input)) {
  // true
}
else {
  // false
}

# 3  
Old 04-04-2010
Thanks for your reply Franklin.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Baiduspider and Forum Performance Issues

For years we blocked Baiduspider due to the fact their bots do not obey the robots.txt directive and can really hurt site performance when they unleash 100 bots on the site each pulling pages many times per second. Last year, I unblocked Baiduspider's IP addresses, and now the problem is back. ... (1 Reply)
Discussion started by: Neo
1 Replies

2. Shell Programming and Scripting

Help to Modify File Name in each function before calling another function.

I have a script which does gunzip, zip and untar. Input to the script is file name and file directory (where file is located) I am reading the input parameters as follows: FILENAME=$1 FILEDIR=$2 I have created 3 functions that are as follows: 1) gunzip file 2) unzip file... (2 Replies)
Discussion started by: pinnacle
2 Replies

3. AIX

AIX 6.1 Memory Performance issues

Good Day Everyone, Just wonder anyone has encounter AIX 6.1 Memory Performance issues ? What I have in my current scenario is we have 3 datastage servers (Segregate server and EE jobs - for those who know Datastage achitect) and 2 db servers(running HA to load balance 4 nodes partitions for... (3 Replies)
Discussion started by: ckwan
3 Replies

4. Solaris

Getcwd performance issues

Hello everyone, recently we have been experiencing performance issues with chmod. We managed to narrow it down to getcwd. The following folder exists: /Folder1/subfol1/subfol2/subfol3 cd /Folder1/subfol1/subfol2/subfol3 truss -D pwd 2>&1 | grep getcwd 0.0001... (4 Replies)
Discussion started by: KotekBury
4 Replies

5. Shell Programming and Scripting

perl -Calling the Subroutine Only if the condition is met

Hello All, I am in the process of learning perl.I have a perl script and based on the arguments passed it would the appropriate subroutine that is defined in the script. Now, I need to check a value that is defined in the Environment variables and should call the subroutine only if the... (1 Reply)
Discussion started by: filter
1 Replies

6. AIX

Performance issues for LPAR with GPFS 3.4

Hi, We have GPFS 3.4 Installed on two AIX 6.1 Nodes. We have 3 GPFS Mount points: /abc01 4TB (Comprises of 14 x 300GB disks from XIV SAN) /abc02 4TB (Comprises of 14 x 300GB disks from XIV SAN) /abc03 1TB ((Comprises of Multiple 300GB disks from XIV SAN) Now these 40... (1 Reply)
Discussion started by: aixromeo
1 Replies

7. Shell Programming and Scripting

SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord but only one record is getting wrote in DB.... Please advise ASAP...:confused: function InsertFtg { FTGSTR="" echo "Saurabh is GREAT $#" let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies

8. Shell Programming and Scripting

Return a value from called function to the calling function

I have two scripts. script1.sh looks -------------------------------- #!/bin/bash display() { echo "Welcome to Unix" } display ----------------------------- Script2.sh #!/bin/bash sh script1.sh //simply calling script1.sh ------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies

9. UNIX for Dummies Questions & Answers

Awk Performance Issues

Hi All, I'm facing an issue in my awk script. The script is processing a large text file having the details of a number of persons, each person's details being written from 100 to 250 tags as given below: 100 START| 101klklk| ... 245 opr| 246 55| 250 END| 100 START| ... 245 pp| 246... (4 Replies)
Discussion started by: pgp_acc1
4 Replies

10. Solaris

raidctl performance issues

using the internal 2 drives mirror was created using raidctl on 100's of our servers . sometime when one drive fails we dont face any issue & we replace the drive with out any problem . but sometimes when one drive fails , system becomes unresponsive and doesnot allow us to login , the only way to... (1 Reply)
Discussion started by: skamal4u
1 Replies
Login or Register to Ask a Question