I have a body of code that has to insure a file exists and if it does load it to the system to be read if it is not true it will create the file in the proper format and save it. I have to do this numerous times and thus i created a function. I was wondering if there is a way to take these numerous similar if statements and cut them down so that it doesn't utilize as large of an if statement set up
Sample code:
//Currently my code calls a function called CheckVal to check a file and a file where the data type exists.
//the call looks like this:
public Object CheckVal (File valPath, File fullPath)
{
//this will then check if it exist using .exists()
if (valPath.exists)
{
//load Value
}
else
{
//Create value
}
return Value;
}
This data is called several times hence why I wish to cut down on the number of calls to these functions to reduce the overall time the program may take. I was hoping a solution may be possible as even the smallest time difference can greatly impact the speed of the program.
Aucun commentaire:
Enregistrer un commentaire