There are times when it feels nice to use the_content filter to make changes in the post content before displaying it to our visitors. But, on certain occasions a more efficient approach would be to filter the content before saving it to database, thus improving the page loading time (less operations on the frontend).
I stumbled on this issue on a recent project where I built some logic to wrap all the images inserted in the post body using these HTML5 tags:

  <img src="" alt="" />
  <figcaption>some image caption text</figcaption>&nbsp;

For some strange reason (which I could’t find out) everytime I saved a post, WordPress little midgets were introducing a carriage return before the figcaption tag which was breaking the posts’ page design.

Filter ‘content_save_pre’

Since I couldn’t understand why WordPress was doing it, even after some swimming in the core files, I decided to write a small function to sanitize the content. So I’ve come up with this:

/** Sanitize post content before post is saved. */
add_filter( 'content_save_pre' , 'my_sanitize_content' , 10, 1);
function my_sanitize_content( $value ) {
  return str_replace("\r<figcaption>", "<figcaption>", $value );

The above function hooks on the content_save_pre filter where you’re able to sanitize post content before it’s inserted in to the database. You may filter other post fields (title, excerpt, …) using the same approach.

After writing this post I dived into the Codex and made my first contribution to the WordPress Codex. Hope it helps!