diff options
| author | gingerBill <bill@gingerbill.org> | 2019-12-27 15:49:52 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-12-27 15:49:52 +0000 |
| commit | f99f351e01dc8140a36c1a9b5568f5081cfa1e70 (patch) | |
| tree | cd981905bb5924532624f375bfb478ea639d1d16 /src/types.cpp | |
| parent | 880c7f01a8ee71f9001ad7d9558753cf8d512845 (diff) | |
Add constant literal expressions
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
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; } |