I have owned .223s with a variety of barrel lengths from 10.25" (Sig 556 pistols) to 30" (F-TR competition rifles). For shooting with good precision at 100 to 300 yd, a barrel anywhere from 16" to 24" can be perfectly adequate. Within that length range, you're largely talking about increasing the velocity slightly with each additional inch of barrel length, anywhere from perhaps 10 to 20 fps per inch of barrel, or thereabouts. Increasing the velocity certainly buys a small amount of resistance to wind deflection for a given weight bullet, but it is not huge.
In your case, I would recommend a couple things. First, if you intend to replace the factory barrel, get yourself an 8-twist or a 7-twist barrel. That will allow you to run heavier, higher BC bullets that will likely have a far greater impact on your precision at 300 yd than will increasing the velocity a few fps with a slightly longer barrel. I would suggest a barrel length of around 26" if you're going to go that route. It's not so long as to be unwieldy, but will also allow you to generate reasonable velocity with heavier bullets. Second, get yourself a high quality barrel from a reputable manufacturer such as Bartlein, Krieger, Brux, etc. (there are many others), and have it chambered with a freebore that allows you to optimally seat bullets in the ~80 gr range. Within reason, you can still be able to load lighter bullets in a rifle with longer freebore, but having the longer freebore provides you with the option of optimally loading the "heavies" that can make a big difference when shooting a .223 in windy conditions. In fact, such a setup would allow you to easily stretch the range out to 500-600 yd, or even farther.