Skip to content

Commit

Permalink
minor range update
Browse files Browse the repository at this point in the history
  • Loading branch information
ncave committed Mar 25, 2019
1 parent fd3a482 commit 426860f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
41 changes: 21 additions & 20 deletions fcs/fcs-fable/test/Platform.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,39 @@ let getRelativePath (pathFrom: string) (pathTo: string) =

open Fable.Core.JsInterop

type private IFileSystem =
abstract readFileSync: string -> byte[]
abstract readFileSync: string * string -> string
abstract writeFileSync: string * string -> unit
module JS =
type IFileSystem =
abstract readFileSync: string -> byte[]
abstract readFileSync: string * string -> string
abstract writeFileSync: string * string -> unit

type private IProcess =
abstract hrtime: unit -> float []
abstract hrtime: float[] -> float[]
type IProcess =
abstract hrtime: unit -> float []
abstract hrtime: float[] -> float[]

type private IPath =
abstract resolve: string -> string
abstract relative: string * string -> string
type IPath =
abstract resolve: string -> string
abstract relative: string * string -> string

let private FileSystem: IFileSystem = importAll "fs"
let private Process: IProcess = importAll "process"
let private Path: IPath = importAll "path"
let FileSystem: IFileSystem = importAll "fs"
let Process: IProcess = importAll "process"
let Path: IPath = importAll "path"

let readAllBytes (filePath: string) = FileSystem.readFileSync(filePath)
let readAllText (filePath: string) = FileSystem.readFileSync(filePath, "utf8").TrimStart('\uFEFF')
let writeAllText (filePath: string) (text: string) = FileSystem.writeFileSync(filePath, text)
let readAllBytes (filePath: string) = JS.FileSystem.readFileSync(filePath)
let readAllText (filePath: string) = JS.FileSystem.readFileSync(filePath, "utf8").TrimStart('\uFEFF')
let writeAllText (filePath: string) (text: string) = JS.FileSystem.writeFileSync(filePath, text)

let measureTime (f: 'a -> 'b) x =
let startTime = Process.hrtime()
let startTime = JS.Process.hrtime()
let res = f x
let elapsed = Process.hrtime(startTime)
let elapsed = JS.Process.hrtime(startTime)
int64 (elapsed.[0] * 1e3 + elapsed.[1] / 1e6), res

let normalizeFullPath (path: string) =
Path.resolve(path).Replace('\\', '/')
JS.Path.resolve(path).Replace('\\', '/')

let getRelativePath (pathFrom: string) (pathTo: string) =
Path.relative(pathFrom, pathTo).Replace('\\', '/')
JS.Path.relative(pathFrom, pathTo).Replace('\\', '/')

#endif

Expand Down
13 changes: 4 additions & 9 deletions fcs/fcs-fable/test/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"name": "fcs-fable-test",
"version": "1.0.0",
"description": "FCS-Fable test",
"keywords": [],
"author": "",
"license": "",
"private": true,
"scripts": {
"build-test": "dotnet run -c Release -p ../../../../Fable/src/dotnet/Fable.Compiler npm-splitter",
"splitter": "node ./node_modules/fable-splitter/dist/cli --commonjs",
Expand All @@ -13,8 +8,8 @@
"bench-dotnet": "dotnet run -c Release -p fcs-fable-bench.fsproj ../fcs-fable.fsproj"
},
"devDependencies": {
"@babel/core": "^7.3.4",
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
"fable-splitter": "^2.1.5"
"@babel/core": "^7.4.0",
"@babel/plugin-transform-modules-commonjs": "^7.4.0",
"fable-splitter": "^2.1.6"
}
}
4 changes: 4 additions & 0 deletions src/fsharp/range.fs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ type FileIndexTable() =
| true, idx ->
// Record the non-normalized entry if necessary
if filePath <> normalizedFilePath then
#if FABLE_COMPILER
(
#else
lock fileToIndexTable (fun () ->
#endif
fileToIndexTable.[filePath] <- idx)

// Return the index
Expand Down

0 comments on commit 426860f

Please sign in to comment.