-
Notifications
You must be signed in to change notification settings - Fork 158
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
Reduce project option duplication, reducing memory usage. #1147
Conversation
[<CustomEquality; NoComparison>] | ||
type LoadedProject = | ||
{ FSharpProjectOptions: FSharpProjectOptions | ||
LanguageVersion: LanguageVersionShim } | ||
|
||
type LoadedProject = | ||
| LoadedProjectFile of LoadedProjectFile | ||
| LoadedScriptFile of LoadedScriptFile | ||
interface IEquatable<LoadedProject> with | ||
member x.Equals(other) = | ||
x.FSharpProjectOptions = other.FSharpProjectOptions | ||
|
||
member x.FSharpProjectOptions = | ||
match x with | ||
| LoadedProjectFile p -> p.FSharpProjectOptions | ||
| LoadedScriptFile p -> p.FSharpProjectOptions | ||
override x.GetHashCode() = x.FSharpProjectOptions.GetHashCode() | ||
|
||
member x.LanguageVersion = | ||
match x with | ||
| LoadedProjectFile p -> p.LanguageVersion | ||
| LoadedScriptFile p -> p.LanguageVersion | ||
override x.Equals(other) = | ||
match other with | ||
| :? LoadedProject as other -> (x :> IEquatable<_>).Equals other | ||
| _ -> false |
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.
We don't really need to keep ProjectOptions
so condensing this type. Also makes it use FSharpProjectOptions
as its equality.
projectOptions | ||
|> List.map (fun o -> | ||
let fso = FCS.mapToFSharpProjectOptions o projectOptions | ||
let fsharpOptions = projectOptions |> FCS.mapManyOptions |> Seq.toList |
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.
This is the main change. We had this in Ionide.ProjInfo
but weren't using it. This prevent recreation of referenced types.
08fadc8
to
c527897
Compare
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.
Heck yeah
WHAT
🤖 Generated by Copilot at 08fadc8
Improved project and script loading to handle multi-targeting scenarios. Replaced the
LoadedProject
discriminated union with a simpler record type. RefactoredloadProject
inAdaptiveFSharpLspServer.fs
to use the new type and logic.🤖 Generated by Copilot at 08fadc8
🔄📝🚀
WHY
I noticed we were creating way to many project options.
After the change it doesn't really show up now.
HOW
🤖 Generated by Copilot at 08fadc8
LoadedProject
type to use a record with custom equality instead of a union ofLoadedProjectFile
andLoadedScriptFile
(link)FCS.mapManyOptions
to handle multiple project options per file and support multi-targeting projects and scripts (link, link, link, link)ProjectFileName
property ofFSharpProjectOptions
instead ofProjectOptions
to avoid null values for scripts (link)LoadedScriptFile
case fromLoadedProject
type (link)