I have to run for about an hour, then I will show you underlying math / pictures for this. I believe it will be more helpful than just sharing code.
As far as performance goes: you can batch lights also be doing several light passes each drawcall (lets say four by feeding shader with arrays)
Anyway, advice (ignore this if your are working on android game tho): Performance of modern computers is insane, perfect optimization cost ridiculous amount of time. Especially if you are single developer working on 2D title there is no point to invest too much time into optimizing every drawcall, obviously, you have to be aware of doing absolutely stupid stuff but don't worry about doing everything in most efficient way. Lot of optimizations can be done later, don't burn yourself over spending too much time over every single detail, when you are not sure just profile your game and then decide if performance cost is worrysome.