Function strtabString [src]

Prototype

pub fn strtabString(self: *Builder, bytes: []const u8) Allocator.Error!StrtabString

Parameters

self: *Builderbytes: []const u8

Source

pub fn strtabString(self: *Builder, bytes: []const u8) Allocator.Error!StrtabString { try self.strtab_string_bytes.ensureUnusedCapacity(self.gpa, bytes.len); try self.strtab_string_indices.ensureUnusedCapacity(self.gpa, 1); try self.strtab_string_map.ensureUnusedCapacity(self.gpa, 1); const gop = self.strtab_string_map.getOrPutAssumeCapacityAdapted(bytes, StrtabString.Adapter{ .builder = self }); if (!gop.found_existing) { self.strtab_string_bytes.appendSliceAssumeCapacity(bytes); self.strtab_string_indices.appendAssumeCapacity(@intCast(self.strtab_string_bytes.items.len)); } return StrtabString.fromIndex(gop.index); }