From 3c1152a53656d155fb68e2ce3f75ef5bad1507b3 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 30 Sep 2021 18:47:48 -0700 Subject: [PATCH] use empty string for empty []const u8 --- src/main.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.zig b/src/main.zig index d092b1c..3868224 100644 --- a/src/main.zig +++ b/src/main.zig @@ -544,7 +544,7 @@ fn nodeToCompletion(arena: *std.heap.ArenaAllocator, list: *std.ArrayList(types. pub fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) []const u8 { const text = handle.document.text; - if (pos_index + 1 >= text.len) return &[0]u8{}; + if (pos_index + 1 >= text.len) return ""; var start_idx = pos_index; while (start_idx > 0 and isSymbolChar(text[start_idx - 1])) { @@ -556,7 +556,7 @@ pub fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) [] end_idx += 1; } - if (end_idx <= start_idx) return &[0]u8{}; + if (end_idx <= start_idx) return ""; return text[start_idx..end_idx]; }