From c8fb048f79964e0b6cdf9d322fc12c71328cfde8 Mon Sep 17 00:00:00 2001
From: Behdad Esfahbod <behdad@behdad.org>
Date: Tue, 7 Jun 2022 09:20:27 -0600
Subject: [PATCH] [gsubgpos] Document caching

---
 src/hb-ot-layout-gsubgpos.hh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index 2674a3e3f..21ddcf7fa 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -894,7 +894,14 @@ struct hb_accelerate_subtables_context_t :
 
     array.push (entry);
 
-    // Cache handling
+    /* Cache handling
+     *
+     * We allow one subtable from each lookup to use a cache. The assumption
+     * being that multiple subtables of the same lookup cannot use a cache
+     * because the resources they would use will collide.  As such, we ask
+     * each subtable to tell us how much it costs (which a cache would avoid),
+     * and we allocate the cache opportunity to the costliest subtable.
+     */
     unsigned cost = cache_cost (obj, hb_prioritize);
     if (cost > cache_user_cost && !array.in_error ())
     {