From 8a86c2f586e907390886279b2f6e8c29b4693c05 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 9 Jul 2013 17:38:08 +0200
Subject: [PATCH] ZSQLCatalog: Also cache misses.

There are a lot of misses in this function because related keys must have
precedence over homonym columns, which makes it cost a *lot* of cpu time
to just return None.
---
 product/ZSQLCatalog/SQLCatalog.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py
index 24ea9ab92f..fc94d7836d 100644
--- a/product/ZSQLCatalog/SQLCatalog.py
+++ b/product/ZSQLCatalog/SQLCatalog.py
@@ -2035,7 +2035,6 @@ class Catalog(Folder,
     try:
       result = related_key_definition_cache[key]
     except KeyError:
-      result = None
       for entire_definition in self.getSQLCatalogRelatedKeyList([key]):
         split_entire_definition = entire_definition.split('|')
         if len(split_entire_definition) != 2:
@@ -2044,8 +2043,9 @@ class Catalog(Folder,
         if split_entire_definition[0].strip() == key:
           result = split_entire_definition[1].strip()
           break
-      if result is not None:
-        related_key_definition_cache[key] = result
+      else:
+        result = None
+      related_key_definition_cache[key] = result
     return result
 
   @transactional_cache_decorator('SQLCatalog._getgetScriptableKeyDict')
-- 
2.30.9