Instead of checking whether package format is sdl or json for every dependency, calculate it once before the loop