From f99f351e01dc8140a36c1a9b5568f5081cfa1e70 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 27 Dec 2019 15:49:52 +0000 Subject: Add constant literal expressions --- src/types.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/types.cpp') diff --git a/src/types.cpp b/src/types.cpp index 7c4e47f12..9b286c8df 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -339,7 +339,15 @@ Selection selection_combine(Selection const &lhs, Selection const &rhs) { Selection sub_selection(Selection const &sel, isize offset) { Selection res = {}; res.index.data = sel.index.data + offset; - res.index.count = sel.index.count - offset; + res.index.count = gb_max(sel.index.count - offset, 0); + res.index.capacity = res.index.count; + return res; +} + +Selection sub_selection_with_length(Selection const &sel, isize offset, isize len) { + Selection res = {}; + res.index.data = sel.index.data + offset; + res.index.count = gb_max(len, gb_max(sel.index.count - offset, 0)); res.index.capacity = res.index.count; return res; } -- cgit v1.2.3