summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-15 16:37:22 -0800
committerscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-15 16:37:22 -0800
commitde33ae22c4ee389afc4a9e15b3edab17d4528321 (patch)
tree6850d7877f4d892e0ae25e5b1c8fc636a6ac6b9e /lib
parenta6e6c0552708166ea052a99bdd9420dcc33536e0 (diff)
downloadthird_party-ruby-git-de33ae22c4ee389afc4a9e15b3edab17d4528321.tar.gz
third_party-ruby-git-de33ae22c4ee389afc4a9e15b3edab17d4528321.tar.xz
third_party-ruby-git-de33ae22c4ee389afc4a9e15b3edab17d4528321.zip
added object content caching
Diffstat (limited to 'lib')
-rw-r--r--lib/git/object.rb6
1 files changed, 4 insertions, 2 deletions
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