@@ -385,6 +385,10 @@ def extension_presence(ext_name)
385385 # @return [Presence] Given an instruction +inst_name+, return the presence.
386386 # If the instruction name isn't found in the portfolio, return nil.
387387 def instruction_presence_obj ( inst_name )
388+ @instruction_presence_obj ||= { }
389+
390+ return @instruction_presence_obj [ inst_name ] unless @instruction_presence_obj [ inst_name ] . nil?
391+
388392 inst = arch . instruction ( inst_name )
389393
390394 raise "Can't find instruction object '#{ inst_name } ' in arch class" if inst . nil?
@@ -399,26 +403,35 @@ def instruction_presence_obj(inst_name)
399403 ext_versions . any? { |ext_ver | inst . defined_by_condition . possibly_satisfied_by? ( ext_ver ) }
400404 end
401405
402- if is_mandatory
403- Presence . new ( Presence . mandatory )
404- elsif is_optional
405- Presence . new ( Presence . optional )
406- else
407- nil
408- end
406+ @instruction_presence_obj [ inst_name ] =
407+ if is_mandatory
408+ Presence . new ( Presence . mandatory )
409+ elsif is_optional
410+ Presence . new ( Presence . optional )
411+ else
412+ nil
413+ end
409414 end
410415
411416 # @return [String] Given an instruction +inst_name+, return the presence as a string.
412417 # If the instruction name isn't found in the portfolio, return "-".
413418 def instruction_presence ( inst_name )
419+ @instruction_presence ||= { }
420+
421+ return @instruction_presence [ inst_name ] unless @instruction_presence [ inst_name ] . nil?
422+
414423 presence_obj = instruction_presence_obj ( inst_name )
415424
416- presence_obj . nil? ? "-" : presence_obj . to_s
425+ @instruction_presence [ inst_name ] = presence_obj . nil? ? "-" : presence_obj . to_s
417426 end
418427
419428 # @return [Presence] Given an CSR +csr_name+, return the presence.
420429 # If the CSR name isn't found in the portfolio, return nil.
421430 def csr_presence_obj ( csr_name )
431+ @csr_presence_obj ||= { }
432+
433+ return @csr_presence_obj [ csr_name ] unless @csr_presence_obj [ csr_name ] . nil?
434+
422435 csr = arch . csr ( csr_name )
423436
424437 raise "Can't find CSR object '#{ csr_name } ' in arch class" if csr . nil?
@@ -433,21 +446,26 @@ def csr_presence_obj(csr_name)
433446 ext_versions . any? { |ext_ver | csr . defined_by_condition . possibly_satisfied_by? ( ext_ver ) }
434447 end
435448
436- if is_mandatory
437- Presence . new ( Presence . mandatory )
438- elsif is_optional
439- Presence . new ( Presence . optional )
440- else
441- nil
442- end
449+ @csr_presence_obj [ csr_name ] =
450+ if is_mandatory
451+ Presence . new ( Presence . mandatory )
452+ elsif is_optional
453+ Presence . new ( Presence . optional )
454+ else
455+ nil
456+ end
443457 end
444458
445459 # @return [String] Given an CSR +csr_name+, return the presence as a string.
446460 # If the CSR name isn't found in the portfolio, return "-".
447461 def csr_presence ( csr_name )
462+ @csr_presence ||= { }
463+
464+ return @csr_presence [ csr_name ] unless @csr_presence [ csr_name ] . nil?
465+
448466 presence_obj = csr_presence_obj ( csr_name )
449467
450- presence_obj . nil? ? "-" : presence_obj . to_s
468+ @csr_presence [ csr_name ] = presence_obj . nil? ? "-" : presence_obj . to_s
451469 end
452470
453471 # Returns the greatest presence string for each of the specified versions.
0 commit comments