sipsorcery icon indicating copy to clipboard operation
sipsorcery copied to clipboard

Change the definition of enum SIPExtensions to allow using as a bitfield

Open randruc opened this issue 9 months ago • 3 comments

Change the definition of enum SIPExtensions to allow using as a bitfieldeld.

In class SIPHeader, members RequiredExtensions and SupportedExtensions can now become bitfields instead of lists of enums. This results in a smaller memory footprint.

Modify static method ParseSIPExtensions accordingly, and eliminate all string concatenations by using a StringBuilder.

[!IMPORTANT] Although this approch is more idiomatic to C#, and reduces the memory footprint of the library, it is important to note that this modifies the public API, as members SupportedExtensions are RequiredExtensions are public. Please let me know what you think about it.

randruc avatar Feb 13 '25 22:02 randruc

You are totally right. I kept the same existing logic of the function, but I agree that the string manipulations are not done the best way, and I can go further if needed.

randruc avatar Feb 14 '25 13:02 randruc

The flag enum is a good improvement. Happy to merge. The change is highly unlikely to affect any library users.

If there are further string optimisations planned it would be better to get them in now.

sipsorcery avatar Feb 14 '25 20:02 sipsorcery

Thanks for the review. That means that the visibility of the member could be restricted. I'll think about it. I will update the submitted code with the suggestions made by @paulomorgado. Now that I know that we don't want to keep the original mechanics of this function, I'll improve that.

randruc avatar Feb 14 '25 21:02 randruc