Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/Compiler/Service/IncrementalBuild.fs
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ type TcInfoExtras =
member x.TcSymbolUses =
x.tcSymbolUses

module ValueOption =
let toOption = function
| ValueSome x -> Some x
| _ -> None

type private SingleFileDiagnostics = (PhasedDiagnostic * FSharpDiagnosticSeverity) array
type private TypeCheck = TcInfo * TcResultsSinkImpl * CheckedImplFile option * string * SingleFileDiagnostics

Expand Down
6 changes: 3 additions & 3 deletions src/Compiler/TypedTree/TypedTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,7 @@ type ModuleOrNamespaceType(kind: ModuleOrNamespaceKind, vals: QueueList<Val>, en
|> List.tryFind (fun v -> match key.TypeForLinkage with
| None -> true
| Some keyTy -> ccu.MemberSignatureEquality(keyTy, v.Type))
|> ValueOptionInternal.ofOption
|> ValueOption.ofOption

/// Get a table of values indexed by logical name
member _.AllValsByLogicalName =
Expand Down Expand Up @@ -4237,7 +4237,7 @@ type UnionCaseRef =
/// Try to dereference the reference
member x.TryUnionCase =
x.TyconRef.TryDeref
|> ValueOptionInternal.bind (fun tcref -> tcref.GetUnionCaseByName x.CaseName |> ValueOptionInternal.ofOption)
|> ValueOption.bind (fun tcref -> tcref.GetUnionCaseByName x.CaseName |> ValueOption.ofOption)

/// Get the attributes associated with the union case
member x.Attribs = x.UnionCase.Attribs
Expand Down Expand Up @@ -4300,7 +4300,7 @@ type RecdFieldRef =
/// Try to dereference the reference
member x.TryRecdField =
x.TyconRef.TryDeref
|> ValueOptionInternal.bind (fun tcref -> tcref.GetFieldByName x.FieldName |> ValueOptionInternal.ofOption)
|> ValueOption.bind (fun tcref -> tcref.GetFieldByName x.FieldName |> ValueOption.ofOption)

/// Get the attributes associated with the compiled property of the record field
member x.PropertyAttribs = x.RecdField.PropertyAttribs
Expand Down
6 changes: 3 additions & 3 deletions src/Compiler/TypedTree/TypedTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3526,11 +3526,11 @@ let IsMatchingFSharpAttributeOpt g attrOpt (Attrib(tcref2, _, _, _, _, _, _)) =

[<return: Struct>]
let (|ExtractAttribNamedArg|_|) nm args =
args |> List.tryPick (function AttribNamedArg(nm2, _, _, v) when nm = nm2 -> Some v | _ -> None) |> ValueOptionInternal.ofOption
args |> List.tryPick (function AttribNamedArg(nm2, _, _, v) when nm = nm2 -> Some v | _ -> None) |> ValueOption.ofOption

Comment on lines 3527 to +3530
Copy link
Contributor

@kerams kerams Jan 27, 2025

Choose a reason for hiding this comment

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

Off topic, but what is the point of this AP returning voption when option is still being created? Doesn't the conversion do nothing but add overhead?

Copy link
Member

Choose a reason for hiding this comment

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

Yes.
A tryPickV equivalent would be better here.

[<return: Struct>]
let (|ExtractILAttributeNamedArg|_|) nm (args: ILAttributeNamedArg list) =
args |> List.tryPick (function nm2, _, _, v when nm = nm2 -> Some v | _ -> None) |> ValueOptionInternal.ofOption
args |> List.tryPick (function nm2, _, _, v when nm = nm2 -> Some v | _ -> None) |> ValueOption.ofOption

[<return: Struct>]
let (|StringExpr|_|) = function Expr.Const (Const.String n, _, _) -> ValueSome n | _ -> ValueNone
Expand Down
12 changes: 0 additions & 12 deletions src/Compiler/Utilities/illib.fs
Original file line number Diff line number Diff line change
Expand Up @@ -715,18 +715,6 @@ module Span =

state

module ValueOptionInternal =

let inline ofOption x =
match x with
| Some x -> ValueSome x
| None -> ValueNone

let inline bind ([<InlineIfLambda>] f) x =
match x with
| ValueSome x -> f x
| ValueNone -> ValueNone

module String =
let make (n: int) (c: char) : string = String(c, n)

Expand Down
6 changes: 0 additions & 6 deletions src/Compiler/Utilities/illib.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,6 @@ module internal ResizeArray =
module internal Span =
val inline exists: predicate: ('T -> bool) -> span: Span<'T> -> bool

module internal ValueOptionInternal =

val inline ofOption: x: 'a option -> 'a voption

val inline bind: f: ('a -> 'b voption) -> x: 'a voption -> 'b voption

module internal String =

val make: n: int -> c: char -> string
Expand Down
13 changes: 0 additions & 13 deletions vsintegration/src/FSharp.Editor/Common/Extensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,6 @@ module Option =
else
None

[<RequireQualifiedAccess>]
module ValueOption =

let inline ofOption o =
match o with
| Some v -> ValueSome v
| _ -> ValueNone

let inline toOption o =
match o with
| ValueSome v -> Some v
| _ -> None

[<RequireQualifiedAccess>]
module IEnumerator =
let chooseV f (e: IEnumerator<'T>) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ type Mode =
| WithSettings of CodeFixesOptions

module ValueOption =
let inline toOption o =
match o with
| ValueSome v -> Some v
| _ -> None

let inline ofOption o =
match o with
| Some v -> ValueSome v
| _ -> ValueNone

let inline either f y o =
match o with
| ValueSome v -> f v
Expand Down
Loading