Blame SOURCES/0011-sepolicy-Another-small-optimization-for-mcs-types.patch

9bbebd
From e54db76a3bff8e911ddd7c7ce834c024d634d9e1 Mon Sep 17 00:00:00 2001
9bbebd
From: Petr Lautrbach <plautrba@redhat.com>
9bbebd
Date: Tue, 28 Feb 2017 21:29:46 +0100
9bbebd
Subject: [PATCH] sepolicy: Another small optimization for mcs types
9bbebd
9bbebd
---
9bbebd
 python/sepolicy/sepolicy/manpage.py | 16 +++++++++++-----
9bbebd
 1 file changed, 11 insertions(+), 5 deletions(-)
9bbebd
9bbebd
diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py
9bbebd
index f8a94fc0..67d39301 100755
9bbebd
--- a/python/sepolicy/sepolicy/manpage.py
9bbebd
+++ b/python/sepolicy/sepolicy/manpage.py
9bbebd
@@ -142,6 +142,15 @@ def _gen_entry_types():
9bbebd
         entry_types = next(sepolicy.info(sepolicy.ATTRIBUTE, "entry_type"))["types"]
9bbebd
     return entry_types
9bbebd
 
9bbebd
+mcs_constrained_types = None
9bbebd
+
9bbebd
+def _gen_mcs_constrained_types():
9bbebd
+    global mcs_constrained_types
9bbebd
+    if mcs_constrained_types is None:
9bbebd
+        mcs_constrained_types = next(sepolicy.info(sepolicy.ATTRIBUTE, "mcs_constrained_type"))
9bbebd
+    return mcs_constrained_types
9bbebd
+
9bbebd
+
9bbebd
 types = None
9bbebd
 
9bbebd
 def _gen_types():
9bbebd
@@ -390,6 +399,7 @@ class ManPage:
9bbebd
         self.types = _gen_types()
9bbebd
         self.exec_types = _gen_exec_types()
9bbebd
         self.entry_types = _gen_entry_types()
9bbebd
+        self.mcs_constrained_types = _gen_mcs_constrained_types()
9bbebd
 
9bbebd
         if self.source_files:
9bbebd
             self.fcpath = self.root + "file_contexts"
9bbebd
@@ -944,11 +954,7 @@ All executeables with the default executable label, usually stored in /usr/bin a
9bbebd
 %s""" % ", ".join(paths))
9bbebd
 
9bbebd
     def _mcs_types(self):
9bbebd
-        try:
9bbebd
-            mcs_constrained_type = next(sepolicy.info(sepolicy.ATTRIBUTE, "mcs_constrained_type"))
9bbebd
-        except StopIteration:
9bbebd
-            return
9bbebd
-        if self.type not in mcs_constrained_type['types']:
9bbebd
+        if self.type not in self.mcs_constrained_types['types']:
9bbebd
             return
9bbebd
         self.fd.write ("""
9bbebd
 .SH "MCS Constrained"
9bbebd
-- 
9bbebd
2.21.0
9bbebd