Skip to content

Refactor SIP Regex usage for performance and clarity#1674

Open
paulomorgado wants to merge 2 commits into
sipsorcery-org:masterfrom
paulomorgado:regex-1
Open

Refactor SIP Regex usage for performance and clarity#1674
paulomorgado wants to merge 2 commits into
sipsorcery-org:masterfrom
paulomorgado:regex-1

Conversation

@paulomorgado
Copy link
Copy Markdown
Contributor

Refactored SIP classes to use pre-compiled or source-generated Regex via [GeneratedRegex] for improved performance and maintainability. Introduced constants for Regex patterns and conditional compilation for .NET 7+ compatibility. Updated string operations and equality checks for consistency and modern C# style. Minor code cleanups included.

Refactored SIP classes to use pre-compiled or source-generated Regex via [GeneratedRegex] for improved performance and maintainability. Introduced constants for Regex patterns and conditional compilation for .NET 7+ compatibility. Updated string operations and equality checks for consistency and modern C# style. Minor code cleanups included.
}

public class SIPCallDescriptor
public partial class SIPCallDescriptor
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason to make these classes partial?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/SIPSorcery/core/SIP/SIPHeader.cs Outdated
catch (Exception excp)
{
throw new SIPValidationException(SIPValidationFieldsEnum.ContactHeader, $"Contact header invalid, parse failed. {excp.Message}");
throw new SIPValidationException(SIPValidationFieldsEnum.ContactHeader, "Contact header invalid, parse failed. " + excp.Message);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your previous PR's are going the other way and update to use string interpolation instead of concatentation. Why is this PR doing the opposite?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOPS! It was a bad rebase. Reverted!

}

public static string[] SplitHeaders(string message)
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the NormalizeFoldedHeaderLines an error? Your PR only added it less than a week ago.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOPS! It was a bad rebase. Reverted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants