diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 632847477b0997b31fa404adfce17e750732370e..d49e429733bf263889897e4be46089ca649cd5bd 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -435,9 +435,6 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $langcode = '', $c
       return $cached->data;
     }
 
-    // See if caching is allowed for this format.
-    $cache = filter_format_allowcache($format);
-
     // Convert all Windows and Mac newlines to a single newline,
     // so filters only need to deal with one possibility.
     $text = str_replace(array("\r\n", "\r"), "\n", $text);
@@ -456,7 +453,7 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $langcode = '', $c
     }
 
     // Store in cache with a minimum expiration time of 1 day.
-    if ($cache) {
+    if (filter_format_allowcache($format)) {
       cache_set($cache_id, $text, 'cache_filter', REQUEST_TIME + (60 * 60 * 24));
     }
   }