Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-03-06 17:52:53 +0400
committernulltoken <emeric.fermas@gmail.com>2012-03-06 17:55:54 +0400
commitd4307c3a2c72c55a9d606be739f8849730d32f47 (patch)
treeb24db2918f55bce1871c01649516e60767151553 /LibGit2Sharp
parentf0178a0665d8d5885877409175891ffcf391a399 (diff)
Reduce the number of in-memory Utf8Marshaler instances
Diffstat (limited to 'LibGit2Sharp')
-rw-r--r--LibGit2Sharp/Core/Utf8Marshaler.cs9
-rw-r--r--LibGit2Sharp/Index.cs2
-rw-r--r--LibGit2Sharp/IndexEntry.cs2
-rw-r--r--LibGit2Sharp/Signature.cs2
4 files changed, 5 insertions, 10 deletions
diff --git a/LibGit2Sharp/Core/Utf8Marshaler.cs b/LibGit2Sharp/Core/Utf8Marshaler.cs
index 13eeae4f..885aa2a5 100644
--- a/LibGit2Sharp/Core/Utf8Marshaler.cs
+++ b/LibGit2Sharp/Core/Utf8Marshaler.cs
@@ -6,8 +6,8 @@ namespace LibGit2Sharp.Core
{
internal class Utf8Marshaler : ICustomMarshaler
{
- static Utf8Marshaler staticInstance;
- readonly bool ownsPointer;
+ private static readonly Utf8Marshaler staticInstance = new Utf8Marshaler();
+ private readonly bool ownsPointer;
internal Utf8Marshaler(bool ownsPointer = false)
{
@@ -89,11 +89,6 @@ namespace LibGit2Sharp.Core
public static ICustomMarshaler GetInstance(string cookie)
{
- if (staticInstance == null)
- {
- return staticInstance = new Utf8Marshaler();
- }
-
return staticInstance;
}
diff --git a/LibGit2Sharp/Index.cs b/LibGit2Sharp/Index.cs
index 41284cab..15dbfba6 100644
--- a/LibGit2Sharp/Index.cs
+++ b/LibGit2Sharp/Index.cs
@@ -17,7 +17,7 @@ namespace LibGit2Sharp
private readonly IndexSafeHandle handle;
private readonly Repository repo;
- private static readonly Utf8Marshaler utf8Marshaler = new Utf8Marshaler();
+ private static readonly Utf8Marshaler utf8Marshaler = new Utf8Marshaler(true);
internal Index(Repository repo)
{
diff --git a/LibGit2Sharp/IndexEntry.cs b/LibGit2Sharp/IndexEntry.cs
index 9126ed47..6749a7db 100644
--- a/LibGit2Sharp/IndexEntry.cs
+++ b/LibGit2Sharp/IndexEntry.cs
@@ -14,7 +14,7 @@ namespace LibGit2Sharp
private Func<FileStatus> state;
- private static readonly Utf8Marshaler marshaler = new Utf8Marshaler();
+ private static readonly Utf8Marshaler marshaler = (Utf8Marshaler)Utf8Marshaler.GetInstance(string.Empty);
/// <summary>
/// State of the version of the <see cref = "Blob" /> pointed at by this <see cref = "IndexEntry" />,
diff --git a/LibGit2Sharp/Signature.cs b/LibGit2Sharp/Signature.cs
index 342c6ee4..e3812e78 100644
--- a/LibGit2Sharp/Signature.cs
+++ b/LibGit2Sharp/Signature.cs
@@ -13,7 +13,7 @@ namespace LibGit2Sharp
private readonly string name;
private readonly string email;
- private static readonly Utf8Marshaler marshaler = new Utf8Marshaler();
+ private static readonly Utf8Marshaler marshaler = (Utf8Marshaler)Utf8Marshaler.GetInstance(string.Empty);
internal Signature(IntPtr signaturePtr)
{