From aebeca33888ad0b1867d63e1a3661598355d5760 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 10 Jul 2018 09:36:27 -0700 Subject: [PATCH] [sqlite] do not wrap results into `Some _` needlessly Summary: All the rows were wrapped in `Some` but that is not needed anywhere. Reviewed By: mbouaziz Differential Revision: D8783310 fbshipit-source-id: b020af3 --- infer/src/IR/SourceFiles.ml | 2 +- infer/src/base/SqliteUtils.ml | 4 ++-- infer/src/base/SqliteUtils.mli | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infer/src/IR/SourceFiles.ml b/infer/src/IR/SourceFiles.ml index ed5855f9d..c5ec6b662 100644 --- a/infer/src/IR/SourceFiles.ml +++ b/infer/src/IR/SourceFiles.ml @@ -82,7 +82,7 @@ let get_all () = let db = ResultsDatabase.get_database () in Sqlite3.prepare db "SELECT source_file FROM source_files" |> SqliteUtils.sqlite_result_rev_list_step db ~log:"getting all source files" - |> List.filter_map ~f:(Option.map ~f:SourceFile.SQLite.deserialize) + |> List.map ~f:SourceFile.SQLite.deserialize let load_proc_names_statement = diff --git a/infer/src/base/SqliteUtils.ml b/infer/src/base/SqliteUtils.ml index db43fd59c..bc6fc7420 100644 --- a/infer/src/base/SqliteUtils.ml +++ b/infer/src/base/SqliteUtils.ml @@ -40,7 +40,7 @@ let sqlite_result_rev_list_step ?finalize:(do_finalize = true) db ~log stmt = match Sqlite3.step stmt with | Sqlite3.Rc.ROW -> (* the operation returned a result, get it *) - let value = Some (Sqlite3.column stmt 0) in + let value = Sqlite3.column stmt 0 in aux (value :: rev_results) | DONE -> rev_results @@ -56,7 +56,7 @@ let sqlite_result_step ?finalize db ~log stmt = | [] -> None | [x] -> - x + Some x | l -> L.die InternalError "%s: zero or one result expected, got %d instead" log (List.length l) diff --git a/infer/src/base/SqliteUtils.mli b/infer/src/base/SqliteUtils.mli index 9032c0219..c19f58c52 100644 --- a/infer/src/base/SqliteUtils.mli +++ b/infer/src/base/SqliteUtils.mli @@ -20,7 +20,7 @@ val finalize : Sqlite3.db -> log:string -> Sqlite3.stmt -> unit (** Finalize the given [stmt]. Raises [Error] on failure. *) val sqlite_result_rev_list_step : - ?finalize:bool -> Sqlite3.db -> log:string -> Sqlite3.stmt -> Sqlite3.Data.t option list + ?finalize:bool -> Sqlite3.db -> log:string -> Sqlite3.stmt -> Sqlite3.Data.t list (** Return a reversed list of results obtained by repeatedly stepping through [stmt] and saving only column 0 of each returned row (all that's been needed so far). *) val sqlite_result_step :