Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor performance improvements #247

Merged
merged 4 commits into from
Mar 20, 2017

Conversation

chescock
Copy link
Collaborator

These are a few other potential performance improvements I noticed while profiling deserialization.

@@ -102,7 +102,7 @@ public override string SerializeToString(object obj)
return string.Join(",", values);
}

internal static readonly Regex UnescapedCommas = new Regex(@"[^\\](,)", RegexOptions.Compiled);
internal static readonly Regex UnescapedCommas = new Regex(@"(?<!\\),", RegexOptions.Compiled);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It matches commas that are not preceded by backslashes. The (?<foo) construct is a zero-width negative lookbehind assertion, which means it ensures the characters before that point don't match the given regex.

Here: https://regex101.com/r/baxiSh/1

Copy link
Collaborator

@rianjs rianjs left a comment

Choose a reason for hiding this comment

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

Oh, I specified collection sizes a while ago. 128 is probably unnecessarily large. 4 would probably suffice in 80%+ of cases, and since 4 is effectively "free", I'm OK with the change.

This was my thinking when I specified initial sizes.

@rianjs rianjs merged commit b5a63b9 into ical-org:master Mar 20, 2017
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