How safemoon keep record of all its holders?

Hello,
I am trying to create a token like safemoon where 5% fee will be distributed among the holders of the token. However i am confused how safemoon keeps record of its holders so that when a transaction happens, all the holders get a %age of the 5% fee. Furthermore how does safemoon manage the GAS fee as sending a small amount to all these holders would need a lot of GAS.
I appricaite any guide and help.
Thanks!

hey @Cryptomatic
Rfi doesn't distribute tokens to each holder but simply modify a value that represent the total share
In this way all the users shares get modified

Check this https://reflect-contract-doc.netlify.app/