Index: wp-includes/rest-api/class-wp-rest-server.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-includes/rest-api/class-wp-rest-server.php	(revision 39923)
+++ wp-includes/rest-api/class-wp-rest-server.php	(revision )
@@ -72,6 +72,17 @@
 	 */
 	protected $endpoints = array();
 
+	/**
+	 * The route map is an associative array with path regexes as the keys. The
+	 * value is an indexed array with the callback function/method as the first
+	 * item, and a bitmask of HTTP methods as the second item (see the class
+	 * constants).
+	 *
+	 * @access protected
+	 * @var array Route map of the routes
+	 */
+	protected $route_map = array();
+
 	/**
 	 * Options defined for the routes.
 	 *
@@ -673,9 +684,33 @@
 		}
 	}
 
+	/**
+	 * Retrieves the internally stored route map.
+	 *
+	 * @access protected
+	 *
+	 * @return array Route map of the routes.
+	 */
+	protected function get_route_map() {
+		return $this->route_map;
+	}
+
+	/**
+	 * Sets the internally stored route map.
+	 *
+	 * @access protected
+	 *
+	 * @param array $route_map Route map of the routes.
+	 */
+	protected function set_route_map( $route_map ) {
+		$this->route_map = $route_map;
+	}
+
 	/**
 	 * Retrieves the route map.
 	 *
+	 * Caches the results internally.
+	 *
 	 * The route map is an associative array with path regexes as the keys. The
 	 * value is an indexed array with the callback function/method as the first
 	 * item, and a bitmask of HTTP methods as the second item (see the class
@@ -695,6 +730,11 @@
 	 *               `'/path/regex' => array( array( $callback, $bitmask ), ...)`.
 	 */
 	public function get_routes() {
+		$endpoints = $this->get_route_map();
+
+		if ( ! empty( $endpoints ) ) {
+			return $endpoints;
+		}
 
 		/**
 		 * Filters the array of available endpoints.
@@ -756,6 +796,7 @@
 				}
 			}
 		}
+		$this->set_route_map( $endpoints );
 
 		return $endpoints;
 	}
