From de33ae22c4ee389afc4a9e15b3edab17d4528321 Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Thu, 15 Nov 2007 16:37:22 -0800 Subject: added object content caching --- lib/git/object.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/git/object.rb b/lib/git/object.rb index 33c3e38..afda923 100644 --- a/lib/git/object.rb +++ b/lib/git/object.rb @@ -10,7 +10,8 @@ module Git attr_accessor :sha, :size, :type, :mode @base = nil - + @contents = nil + def initialize(base, sha) @base = base @sha = sha.to_s @@ -18,8 +19,9 @@ module Git setup end + # caches the contents of this call in memory def contents - @base.lib.object_contents(@sha) + @contents || @contents = @base.lib.object_contents(@sha) end def contents_array -- cgit