Abu Hurayrah reported, attributing it to the Prophet ﷺ, who said, "Hasten with the funeral. If the deceased was righteous, you are bringing him toward what is good. If he was otherwise, you are setting down a burden from your shoulders."
حدثنا أحمد بن منيع حدثنا سفيان بن عيينة عن الزهري سمع سعيد بن المسيب
يبلغ به النبي ﷺ قال أسرعوا بالجنازة فإن يكن خيرا تقدموها إليه وإن يكن شرا تضعوه عن رقابكم
Agreed upon (by Bukhari and Muslim). Bukhari narrated it in the chapters on funerals, in the section on hastening with the funeral, hadith no. 1315, and Muslim, hadith no. 944, from the hadith of Ibn Uyayna, with this wording.On this topic there is also a narration from Abu Bakra [Abu Dawud, hadith no. 3182].