Atlassian interview question

How would you optimize this operational function?