Confirmed.  str_replace is not necessary here
$category = "Foo Bar";
echo Title::makeTitleSafe( NS_CATEGORY, $category, false, false )->getDbKey();
-> Foo_Bar
echo Title::makeTitleSafe( NS_CATEGORY, str_replace( ' ', '_', $category ), false, false )->getDbKey();
-> Foo_Bar