Software /
code /
prosody
File
teal-src/util/human/io.d.tl @ 12763:d26eefe98d09
util.dbuffer: Add efficient shortcuts for discard() in certain cases
If the buffer is already empty, nothing to do. If we're throwing away the
whole buffer, we can just empty it and avoid read_chunk() (which in turn
may collapse()). These shortcuts are much more efficient.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 11 Oct 2022 11:37:55 +0100 |
parent | 12613:a27870dcaf24 |
line wrap: on
line source
local record lib getchar : function (n : integer) : string getline : function () : string getpass : function () : string show_yesno : function (prompt : string) : boolean read_password : function () : string show_prompt : function (prompt : string) : boolean printf : function (fmt : string, ... : any) padleft : function (s : string, width : integer) : string padright : function (s : string, width : integer) : string -- {K:V} vs T ? record tablerow<K,V> width : integer | string -- generate an 1..100 % enum? title : string mapper : function (V, {K:V}) : string key : K enum alignments "left" "right" end align : alignments end type getrow = function<K,V> ({ K : V }) : string table : function<K,V> ({ tablerow<K,V> }, width : integer) : getrow<K,V> end return lib