@@ -47,24 +47,24 @@ public virtual TreeEntry this[string relativePath]
4747get { return RetrieveFromPath ( relativePath ) ; }
4848}
4949
50- private TreeEntry RetrieveFromPath ( FilePath relativePath )
50+ private unsafe TreeEntry RetrieveFromPath ( FilePath relativePath )
5151{
5252if ( relativePath . IsNullOrEmpty ( ) )
5353{
5454return null ;
5555}
5656
57- using ( TreeEntrySafeHandle_Owned treeEntryPtr = Proxy . git_tree_entry_bypath ( repo . Handle , Id , relativePath ) )
57+ using ( TreeEntryOwnedHandle treeEntry = Proxy . git_tree_entry_bypath ( repo . Handle , Id , relativePath ) )
5858{
59- if ( treeEntryPtr == null )
59+ if ( treeEntry == null )
6060{
6161return null ;
6262}
6363
6464string posixPath = relativePath . Posix ;
6565string filename = posixPath . Split ( '/' ) . Last ( ) ;
6666string parentPath = posixPath . Substring ( 0 , posixPath . Length - filename . Length ) ;
67- return new TreeEntry ( treeEntryPtr , Id , repo , path . Combine ( parentPath ) ) ;
67+ return new TreeEntry ( treeEntry . Handle , Id , repo , path . Combine ( parentPath ) ) ;
6868}
6969}
7070
@@ -75,6 +75,11 @@ internal string Path
7575
7676 #region IEnumerable<TreeEntry> Members
7777
78+ unsafe TreeEntry byIndex ( ObjectSafeWrapper obj , uint i , ObjectId parentTreeId , Repository repo , FilePath parentPath )
79+ {
80+ return new TreeEntry ( Proxy . git_tree_entry_byindex ( obj . ObjectPtr , i ) , parentTreeId , repo , parentPath ) ;
81+ }
82+
7883/// <summary>
7984/// Returns an enumerator that iterates through the collection.
8085/// </summary>
@@ -83,10 +88,8 @@ public virtual IEnumerator<TreeEntry> GetEnumerator()
8388{
8489using ( var obj = new ObjectSafeWrapper ( Id , repo . Handle ) )
8590{
86- for ( uint i = 0 ; i < Count ; i ++ )
87- {
88- TreeEntrySafeHandle handle = Proxy . git_tree_entry_byindex ( obj . ObjectPtr , i ) ;
89- yield return new TreeEntry ( handle , Id , repo , path ) ;
91+ for ( uint i = 0 ; i < Count ; i ++ ) {
92+ yield return byIndex ( obj , i , Id , repo , path ) ;
9093}
9194}
9295}
0 commit comments