The advantage of longer barrels comes when you use iron sights. But it has to do with the longer sight radius then the length of the barrel.
I like 24-26 inch barrels for my '06s, I have a 29 inch barrel for my 1000 yard target rifle.
But as to shooting, or accuracy wise, the most accurate 30 cal barrel is about 18 inches as determine by Dr. Mann "The Bullets flght from powder to target". Confirmed by the army who use 18 inch barrels in their Mann Accuracy Devices, use to test military ammo.
Other criteria comes into play, for example the M14 in 308. It needs a 22 inch barrel with its flash hider. Reason being that using M118, there is no detectable muzzle flash at night.
As to the 30-30. 18 inches for convience but again the sight radius comes into play (because most 30-30s use iron sights).
In the '06, using the 208 -220 match bullets, you need the longer barrel to burn the slower powders those heavy bullets need to make work.