Verified Commit e8213708 authored by Raphaël Proust's avatar Raphaël Proust Committed by Marco Stronati

Alpha/Refactor: use return_*

Replaces some allocations of common return values by preallocated constants.
This is a cosmetic change that does not change the semantics.
parent dcec0442
......@@ -212,7 +212,7 @@ let rec longer_than l n =
let record_proposals ctxt delegate proposals =
begin match proposals with
| [] -> fail Empty_proposal
| _ :: _ -> return ()
| _ :: _ -> return_unit
end >>=? fun () ->
Vote.get_current_period_kind ctxt >>=? function
| Proposal ->
......
......@@ -297,7 +297,7 @@ module Delegate = struct
| None ->
(* This case is only when called from `set_active`, when creating
a contract. *)
return false
return_false
let add_amount c delegate amount =
ensure_inited c delegate >>=? fun c ->
......
......@@ -1617,7 +1617,7 @@ and parse_instr
let log_stack ctxt loc stack_ty aft =
match type_logger, script_instr with
| None, _
| Some _, (Seq (-1, _) | Int _ | String _ | Bytes _) -> return ()
| Some _, (Seq (-1, _) | Int _ | String _ | Bytes _) -> return_unit
| Some log, (Prim _ | Seq _) ->
(* Unparsing for logging done in an unlimited context as this
is used only by the client and not the protocol *)
......@@ -1625,7 +1625,7 @@ and parse_instr
unparse_stack ctxt stack_ty >>=? fun (stack_ty, _) ->
unparse_stack ctxt aft >>=? fun (aft, _) ->
log loc stack_ty aft;
return ()
return_unit
in
let return :
context -> bef judgement -> (bef judgement * context) tzresult Lwt.t = fun ctxt judgement ->
......
......@@ -111,8 +111,8 @@ let register () =
register0 S.current_proposal begin fun ctxt () () ->
(* this would be better implemented using get_option in get_current_proposal *)
Vote.get_current_proposal ctxt >>= function
| Ok p -> return (Some p)
| Error [Raw_context.Storage_error (Missing_key _)] -> return None
| Ok p -> return_some p
| Error [Raw_context.Storage_error (Missing_key _)] -> return_none
| (Error _ as e) -> Lwt.return e
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment