-
Notifications
You must be signed in to change notification settings - Fork 224
Low hanging fruit performance improvements from profiling session #1167
Conversation
@@ -443,7 +443,7 @@ private static IEnumerable<string> GetSourcePatternCore(JObject rawProject, stri | |||
} | |||
|
|||
// Assume it's an array (it should explode if it's not) | |||
return token.ToObject<string[]>().SelectMany(GetSourcesSplit); | |||
return token.Select(t => t.Value<string>()).SelectMany(GetSourcesSplit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add an extension method, ValueAsArray:
script.Value.Select(s => s.Value<string>()).ToArray()
script.ValueAsArray<string>()
You can have an overload that takes a property name as well:
foo["something"]?.ValueAsArray<string>()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And use it everywhere there's a ToObject<string[]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'll update the PR with this feedback.
This PR addresses the below bullet from this bug: #1147 Don't use Tracing system for logging, use Console.WriteLine for now. Trace loads the entire configuration stack.
This is to address the following bullet on bug : #1147 Don't use ToObject when parsing global/project.json, that causes the data contract serialization stack to load in JSON.NET which isn't required at all.
@davidfowl Updated PR. |
globalSettings.ProjectSearchPaths = projectSearchPaths == null ? new string[] { } : projectSearchPaths.ToObject<string[]>(); | ||
globalSettings.ProjectSearchPaths = projectSearchPaths == null ? | ||
new string[] { } : | ||
projectSearchPaths.Select(p => p.Value<string>()).ToArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValueAsArray()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah.. fixed.
/CC @muratg |
{ | ||
public static T[] ValueAsArray<T>(this JToken jToken) | ||
{ | ||
return jToken.Select(a => a.Value<T>()).ToArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a null check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All callers handle the null here. But it wouldn't hurt adding a null check.
1 similar comment
merged : f748be5 |
This PR addresses the below bullet from this bug: #1147
Don't use Tracing system for logging, use Console.WriteLine for now. Trace loads the entire configuration stack.
@davidfowl