may be a good idea to move this in a more generic helper (out of the perf-specific code). Maybe it already exists?