Skip to content

Commit

Permalink
Revert "Perf: Small improvements (#963)"
Browse files Browse the repository at this point in the history
This reverts commit 9ebafbd.

# Conflicts:
#	src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs
  • Loading branch information
cheenamalhotra committed Aug 21, 2024
1 parent 286170d commit f67e874
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -757,37 +757,29 @@ internal static Version GetAssemblyVersion()
// This method assumes dataSource parameter is in TCP connection string format.
internal static bool IsAzureSqlServerEndpoint(string dataSource)
{
int length = dataSource.Length;
// remove server port
int foundIndex = dataSource.LastIndexOf(',');
if (foundIndex >= 0)
int i = dataSource.LastIndexOf(',');
if (i >= 0)
{
length = foundIndex;
dataSource = dataSource.Substring(0, i);
}

// check for the instance name
foundIndex = dataSource.LastIndexOf('\\', length - 1, length - 1);
if (foundIndex > 0)
i = dataSource.LastIndexOf('\\');
if (i >= 0)
{
length = foundIndex;
dataSource = dataSource.Substring(0, i);
}

// trim trailing whitespace
while (length > 0 && char.IsWhiteSpace(dataSource[length - 1]))
{
length -= 1;
}
// trim redundant whitespace
dataSource = dataSource.Trim();

// check if servername end with any azure endpoints
for (int index = 0; index < AzureSqlServerEndpoints.Length; index++)
for (i = 0; i < AzureSqlServerEndpoints.Length; i++)
{
string endpoint = AzureSqlServerEndpoints[index];
if (length > endpoint.Length)
if (dataSource.EndsWith(AzureSqlServerEndpoints[i], StringComparison.OrdinalIgnoreCase))
{
if (string.Compare(dataSource, length - endpoint.Length, endpoint, 0, endpoint.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
return true;
}
return true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ internal TdsParserStateObject(TdsParser parser)
// Construct a physical connection
Debug.Assert(null != parser, "no parser?");
_parser = parser;
_onTimeoutAsync = OnTimeoutAsync;

// For physical connection, initialize to default login packet size.
SetPacketSize(TdsEnums.DEFAULT_LOGIN_PACKET_SIZE);
Expand All @@ -285,7 +284,6 @@ internal TdsParserStateObject(TdsParser parser, TdsParserStateObject physicalCon
// Construct a MARS session
Debug.Assert(null != parser, "no parser?");
_parser = parser;
_onTimeoutAsync = OnTimeoutAsync;
SniContext = SniContext.Snix_GetMarsSession;

Debug.Assert(null != _parser._physicalStateObj, "no physical session?");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ internal void TryScopeLeaveEvent(long scopeId)

#region Execution Trace
[NonEvent]
internal void TryBeginExecuteEvent(int objectId, Guid? connectionId, string commandText, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "")
internal void TryBeginExecuteEvent(int objectId, object connectionId, string commandText, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "")
{
if (Log.IsExecutionTraceEnabled())
{
Expand All @@ -518,7 +518,7 @@ internal void TryBeginExecuteEvent(int objectId, Guid? connectionId, string comm
}

[NonEvent]
internal void TryEndExecuteEvent(int objectId, Guid? connectionId, int compositeState, int sqlExceptionNumber, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "")
internal void TryEndExecuteEvent(int objectId, object connectionId, int compositeState, int sqlExceptionNumber, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "")
{
if (Log.IsExecutionTraceEnabled())
{
Expand Down

0 comments on commit f67e874

Please sign in to comment.