KJV
For it came to pass, when David was in
Edom, and Joab the captain of the host was gone up to bury the slain, after
he had smitten every male in Edom;
BSB
Earlier, when David was in Edom, Joab the commander of the army had gone to bury the dead and had struck down every male in Edom.