<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -31,7 +31,6 @@ module ApplicationHelper
   end
 
   def get_relationship_description(edge)
-
     case edge.start_node.class.to_s
       when &quot;Person&quot;
         if (edge.end_date == &quot;&quot; || edge.end_date &gt; Date.today.to_s) then
@@ -54,10 +53,15 @@ module ApplicationHelper
           @link_desc = &quot;link_desc_male_past&quot;
         end
     end
-    xml = File.open(&quot;#{RAILS_ROOT}/config/relationships.xml&quot;)
-    doc = Document.new(xml)
-    @xpath_query = '//relationships/relationship[@name=&quot;' + edge.name + '&quot;]/' + @link_desc
-    @rel_desc = XPath.first(doc, @xpath_query).text
+    @@cache ||= {}
+    unless @@cache[edge.name]
+      xml = File.open(&quot;#{RAILS_ROOT}/config/relationships.xml&quot;)
+      doc = Document.new(xml)
+      xpath_query = '//relationships/relationship[@name=&quot;' + edge.name + '&quot;]/' + @link_desc
+      @@cache[edge.name] = XPath.first(doc, xpath_query).text
+      xml.close
+    end
+    @rel_desc = @@cache[edge.name]
 
   end
   
@@ -103,13 +107,17 @@ module ApplicationHelper
             target_type = &quot;reference&quot;
         end
     end
-    xml = File.open(&quot;#{RAILS_ROOT}/config/relationships.xml&quot;)
-    doc = Document.new(xml)
-    @drop_list_display = '//relationships/relationship[@subject=&quot;' + origin_type + '&quot; and @object=&quot;' + target_type + '&quot;]/option' # /text() will return just node values
-    @drop_list_display_hash = XPath.match(doc, @drop_list_display)
 
-    return @drop_list_display_hash
-       
+    @@cache2 ||= {}
+    key = origin_type + target_type
+    unless @@cache2[key]
+      xml = File.open(&quot;#{RAILS_ROOT}/config/relationships.xml&quot;)
+      doc = Document.new(xml)
+      drop_list_display = '//relationships/relationship[@subject=&quot;' + origin_type + '&quot; and @object=&quot;' + target_type + '&quot;]/option' # /text() will return just node values
+      @@cache2[key] = XPath.match(doc, drop_list_display)
+      xml.close
+    end
+    return @@cache2[key]
   end
   
  # generic traverser to 2 levels deep for entire link set - can easily replace with filtered search like /views/shared/_filtered_target.html.haml</diff>
      <filename>app/helpers/application_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>00cb223035e6a4623ec7b77d21df66252b237302</id>
    </parent>
  </parents>
  <author>
    <name>andreas</name>
    <email>andreas@andreas-xps16.(none)</email>
  </author>
  <url>http://github.com/andreasronge/peoplemap/commit/f75d762e19b9b9830b17baa8a761f7b9a8412a89</url>
  <id>f75d762e19b9b9830b17baa8a761f7b9a8412a89</id>
  <committed-date>2009-10-19T13:32:44-07:00</committed-date>
  <authored-date>2009-10-19T13:32:44-07:00</authored-date>
  <message>a very dirty fix for a performance problem parsing XML</message>
  <tree>f81e7604b37b89fe6d7306fd0fc3f3fe8c2f8ff5</tree>
  <committer>
    <name>andreas</name>
    <email>andreas@andreas-xps16.(none)</email>
  </committer>
</commit>
