Which would be more efficient when checking if GetAsync was Successful?
I am talking about the return result parts of the code
if success then -- if successful
if result then -- if Data
return result -- returns result
else -- If no Data
return table.clone(self.Data) -- returns new Data
end
else -- if Failed
return -- returns nothing
end
if success then -- if successful
return result or table.clone(self.Data) -- Result or new Data
else -- if Failed
return -- returns nothing
end
Sorry if the Topic is a bit misleading, or too vague btw.
The second might be slightly more performant, but it would be so small that it wouldn’t matter which one you use. Choose which one is more readable to you.
I think the question is about how to handle the return better, splitted in an if statement or by using or.
Adding the not makes no difference at all for the question:
if not success then
return -- nothing
else
return result or table.clone(self.Data)
end
…
if success then
return result or table.clone(self.Data)
else
return -- nothing
end