SWEEP: MemberwiseClone() doesn't throw exceptions in .NET, so there is no need to place it in a try/catch block. There is also no need to cast the result if we don't need access to its members. (#259)
diff --git a/src/Lucene.Net/Search/Query.cs b/src/Lucene.Net/Search/Query.cs
index c2825d6..26e86f4 100644
--- a/src/Lucene.Net/Search/Query.cs
+++ b/src/Lucene.Net/Search/Query.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
namespace Lucene.Net.Search
@@ -117,14 +117,7 @@
/// Returns a clone of this query. </summary>
public virtual object Clone()
{
- try
- {
- return (Query)base.MemberwiseClone();
- }
- catch (Exception e)
- {
- throw new Exception("Clone not supported: " + e.Message);
- }
+ return MemberwiseClone(); // LUCENENET: MemberwiseClone() never throws in .NET and there is no need to cast the result here.
}
public override int GetHashCode()
diff --git a/src/Lucene.Net/Util/InfoStream.cs b/src/Lucene.Net/Util/InfoStream.cs
index d29a684..30e8014 100644
--- a/src/Lucene.Net/Util/InfoStream.cs
+++ b/src/Lucene.Net/Util/InfoStream.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using Lucene.Net.Diagnostics;
namespace Lucene.Net.Util
@@ -110,14 +110,7 @@
/// </summary>
public virtual object Clone()
{
- try
- {
- return (InfoStream)base.MemberwiseClone();
- }
- catch (InvalidOperationException e)
- {
- throw new Exception(e.ToString(), e);
- }
+ return MemberwiseClone(); // LUCENENET: No exception can occur in .NET and there is no need to cast.
}
}
}
\ No newline at end of file