The built-in defragmenter in Windows does not compact files to remove free space between files. So even if you've got files sitting at the very end of the drive with 10 gigs of free space between them and the rest of the files, it will leave them there unless they actually get fragmented.
The built-in defragmenter DOES perform optimizations based on usage. That's one of the major features Microsoft touts for increasing performance with XP. The system tracks the way program files load, in order to move the most needed parts towards the beginning of the drive. But it only does that with executables and DLL files as far as I know. Everything else is just defragmented and left where it is, again without regard to reducing the free space between files. (XP by default automatically performs this optimization during idle periods every 3 days, whether you actually run the defragmenter or not. It does not defragment every other file at that time though.)
For the most part, the built-in defragmenter is eliminated fragmentation-related performance loss. For most people there's no need to go any further. If you want to squeeze the last bit of performance out (which translates into almost unnoticeable differences usually) then you can get a 3rd party program like Diskeeper, Norton Utilities or PerfectDisk to perform a more thorough defragment. Those other programs do in some cases also perform more optimizations of the files based on usage.