Skip to content

Commit c2acd95

Browse files
committed
std.mem: Rename splitFull/tokenizeFull to splitSequence/tokenizeSequence
I think this makes the name less ambiguous and more obvious that the suffix applies to the `delimiter`.
1 parent 982f5af commit c2acd95

File tree

4 files changed

+62
-62
lines changed

4 files changed

+62
-62
lines changed

lib/std/mem.zig

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ test "byteSwapAllFields" {
18621862
}, s);
18631863
}
18641864

1865-
/// Deprecated: use `tokenizeAny`, `tokenizeFull`, or `tokenizeScalar`
1865+
/// Deprecated: use `tokenizeAny`, `tokenizeSequence`, or `tokenizeScalar`
18661866
pub const tokenize = tokenizeAny;
18671867

18681868
/// Returns an iterator that iterates over the slices of `buffer` that are not
@@ -1875,9 +1875,9 @@ pub const tokenize = tokenizeAny;
18751875
/// If none of `delimiters` exist in buffer,
18761876
/// the iterator will return `buffer`, null, in that order.
18771877
///
1878-
/// See also: `tokenizeFull`, `tokenizeScalar`,
1879-
/// `splitFull`,`splitAny`, `splitScalar`,
1880-
/// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar`
1878+
/// See also: `tokenizeSequence`, `tokenizeScalar`,
1879+
/// `splitSequence`,`splitAny`, `splitScalar`,
1880+
/// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar`
18811881
pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) TokenIterator(T, .any) {
18821882
return .{
18831883
.index = 0,
@@ -1889,7 +1889,7 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T
18891889
/// Returns an iterator that iterates over the slices of `buffer` that are not
18901890
/// the sequence in `delimiter`.
18911891
///
1892-
/// `tokenizeFull(u8, "<>abc><def<><>ghi", "<>")` will return slices
1892+
/// `tokenizeSequence(u8, "<>abc><def<><>ghi", "<>")` will return slices
18931893
/// for "abc><def", "ghi", null, in that order.
18941894
///
18951895
/// If `buffer` is empty, the iterator will return null.
@@ -1898,9 +1898,9 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T
18981898
/// The delimiter length must not be zero.
18991899
///
19001900
/// See also: `tokenizeAny`, `tokenizeScalar`,
1901-
/// `splitFull`,`splitAny`, and `splitScalar`
1902-
/// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar`
1903-
pub fn tokenizeFull(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .full) {
1901+
/// `splitSequence`,`splitAny`, and `splitScalar`
1902+
/// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar`
1903+
pub fn tokenizeSequence(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .sequence) {
19041904
assert(delimiter.len != 0);
19051905
return .{
19061906
.index = 0,
@@ -1919,9 +1919,9 @@ pub fn tokenizeFull(comptime T: type, buffer: []const T, delimiter: []const T) T
19191919
/// If `delimiter` does not exist in buffer,
19201920
/// the iterator will return `buffer`, null, in that order.
19211921
///
1922-
/// See also: `tokenizeAny`, `tokenizeFull`,
1923-
/// `splitFull`,`splitAny`, and `splitScalar`
1924-
/// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar`
1922+
/// See also: `tokenizeAny`, `tokenizeSequence`,
1923+
/// `splitSequence`,`splitAny`, and `splitScalar`
1924+
/// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar`
19251925
pub fn tokenizeScalar(comptime T: type, buffer: []const T, delimiter: T) TokenIterator(T, .scalar) {
19261926
return .{
19271927
.index = 0,
@@ -1971,7 +1971,7 @@ test "tokenizeScalar" {
19711971
try testing.expect(it16.next() == null);
19721972
}
19731973

1974-
test "tokenizeAny (multibyte)" {
1974+
test "tokenizeAny" {
19751975
var it = tokenizeAny(u8, "a|b,c/d e", " /,|");
19761976
try testing.expect(eql(u8, it.next().?, "a"));
19771977
try testing.expect(eql(u8, it.peek().?, "b"));
@@ -1999,8 +1999,8 @@ test "tokenizeAny (multibyte)" {
19991999
try testing.expect(it16.next() == null);
20002000
}
20012001

2002-
test "tokenizeFull" {
2003-
var it = tokenizeFull(u8, "a<>b<><>c><>d><", "<>");
2002+
test "tokenizeSequence" {
2003+
var it = tokenizeSequence(u8, "a<>b<><>c><>d><", "<>");
20042004
try testing.expectEqualStrings("a", it.next().?);
20052005
try testing.expectEqualStrings("b", it.peek().?);
20062006
try testing.expectEqualStrings("b", it.next().?);
@@ -2009,7 +2009,7 @@ test "tokenizeFull" {
20092009
try testing.expect(it.next() == null);
20102010
try testing.expect(it.peek() == null);
20112011

2012-
var it16 = tokenizeFull(
2012+
var it16 = tokenizeSequence(
20132013
u16,
20142014
std.unicode.utf8ToUtf16LeStringLiteral("a<>b<><>c><>d><"),
20152015
std.unicode.utf8ToUtf16LeStringLiteral("<>"),
@@ -2036,7 +2036,7 @@ test "tokenize (reset)" {
20362036
try testing.expect(it.next() == null);
20372037
}
20382038
{
2039-
var it = tokenizeFull(u8, "<><>abc<>def<><>ghi<>", "<>");
2039+
var it = tokenizeSequence(u8, "<><>abc<>def<><>ghi<>", "<>");
20402040
try testing.expect(eql(u8, it.next().?, "abc"));
20412041
try testing.expect(eql(u8, it.next().?, "def"));
20422042
try testing.expect(eql(u8, it.next().?, "ghi"));
@@ -2063,23 +2063,23 @@ test "tokenize (reset)" {
20632063
}
20642064
}
20652065

2066-
/// Deprecated: use `splitFull`, `splitAny`, or `splitScalar`
2067-
pub const split = splitFull;
2066+
/// Deprecated: use `splitSequence`, `splitAny`, or `splitScalar`
2067+
pub const split = splitSequence;
20682068

20692069
/// Returns an iterator that iterates over the slices of `buffer` that
20702070
/// are separated by the byte sequence in `delimiter`.
20712071
///
2072-
/// `splitFull(u8, "abc||def||||ghi", "||")` will return slices
2072+
/// `splitSequence(u8, "abc||def||||ghi", "||")` will return slices
20732073
/// for "abc", "def", "", "ghi", null, in that order.
20742074
///
20752075
/// If `delimiter` does not exist in buffer,
20762076
/// the iterator will return `buffer`, null, in that order.
20772077
/// The delimiter length must not be zero.
20782078
///
2079-
/// See also: `splitAny`, `splitScalar`, `splitBackwardsFull`,
2079+
/// See also: `splitAny`, `splitScalar`, `splitBackwardsSequence`,
20802080
/// `splitBackwardsAny`,`splitBackwardsScalar`,
2081-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2082-
pub fn splitFull(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .full) {
2081+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
2082+
pub fn splitSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .sequence) {
20832083
assert(delimiter.len != 0);
20842084
return .{
20852085
.index = 0,
@@ -2097,9 +2097,9 @@ pub fn splitFull(comptime T: type, buffer: []const T, delimiter: []const T) Spli
20972097
/// If none of `delimiters` exist in buffer,
20982098
/// the iterator will return `buffer`, null, in that order.
20992099
///
2100-
/// See also: `splitFull`, `splitScalar`, `splitBackwardsFull`,
2100+
/// See also: `splitSequence`, `splitScalar`, `splitBackwardsSequence`,
21012101
/// `splitBackwardsAny`,`splitBackwardsScalar`,
2102-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2102+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
21032103
pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitIterator(T, .any) {
21042104
return .{
21052105
.index = 0,
@@ -2117,9 +2117,9 @@ pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) Spli
21172117
/// If `delimiter` does not exist in buffer,
21182118
/// the iterator will return `buffer`, null, in that order.
21192119
///
2120-
/// See also: `splitFull`, `splitAny`, `splitBackwardsFull`,
2120+
/// See also: `splitSequence`, `splitAny`, `splitBackwardsSequence`,
21212121
/// `splitBackwardsAny`,`splitBackwardsScalar`,
2122-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2122+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
21232123
pub fn splitScalar(comptime T: type, buffer: []const T, delimiter: T) SplitIterator(T, .scalar) {
21242124
return .{
21252125
.index = 0,
@@ -2167,8 +2167,8 @@ test "splitScalar" {
21672167
try testing.expect(it16.next() == null);
21682168
}
21692169

2170-
test "splitFull (multibyte)" {
2171-
var it = splitFull(u8, "a, b ,, c, d, e", ", ");
2170+
test "splitSequence" {
2171+
var it = splitSequence(u8, "a, b ,, c, d, e", ", ");
21722172
try testing.expectEqualSlices(u8, it.first(), "a");
21732173
try testing.expectEqualSlices(u8, it.rest(), "b ,, c, d, e");
21742174
try testing.expectEqualSlices(u8, it.next().?, "b ,");
@@ -2177,7 +2177,7 @@ test "splitFull (multibyte)" {
21772177
try testing.expectEqualSlices(u8, it.next().?, "e");
21782178
try testing.expect(it.next() == null);
21792179

2180-
var it16 = splitFull(
2180+
var it16 = splitSequence(
21812181
u16,
21822182
std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"),
21832183
std.unicode.utf8ToUtf16LeStringLiteral(", "),
@@ -2221,7 +2221,7 @@ test "splitAny" {
22212221

22222222
test "split (reset)" {
22232223
{
2224-
var it = splitFull(u8, "abc def ghi", " ");
2224+
var it = splitSequence(u8, "abc def ghi", " ");
22252225
try testing.expect(eql(u8, it.first(), "abc"));
22262226
try testing.expect(eql(u8, it.next().?, "def"));
22272227
try testing.expect(eql(u8, it.next().?, "ghi"));
@@ -2261,23 +2261,23 @@ test "split (reset)" {
22612261
}
22622262
}
22632263

2264-
/// Deprecated: use `splitBackwardsFull`, `splitBackwardsAny`, or `splitBackwardsScalar`
2265-
pub const splitBackwards = splitBackwardsFull;
2264+
/// Deprecated: use `splitBackwardsSequence`, `splitBackwardsAny`, or `splitBackwardsScalar`
2265+
pub const splitBackwards = splitBackwardsSequence;
22662266

22672267
/// Returns an iterator that iterates backwards over the slices of `buffer` that
22682268
/// are separated by the sequence in `delimiter`.
22692269
///
2270-
/// `splitBackwardsFull(u8, "abc||def||||ghi", "||")` will return slices
2270+
/// `splitBackwardsSequence(u8, "abc||def||||ghi", "||")` will return slices
22712271
/// for "ghi", "", "def", "abc", null, in that order.
22722272
///
22732273
/// If `delimiter` does not exist in buffer,
22742274
/// the iterator will return `buffer`, null, in that order.
22752275
/// The delimiter length must not be zero.
22762276
///
22772277
/// See also: `splitBackwardsAny`, `splitBackwardsScalar`,
2278-
/// `splitFull`, `splitAny`,`splitScalar`,
2279-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2280-
pub fn splitBackwardsFull(comptime T: type, buffer: []const T, delimiter: []const T) SplitBackwardsIterator(T, .full) {
2278+
/// `splitSequence`, `splitAny`,`splitScalar`,
2279+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
2280+
pub fn splitBackwardsSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitBackwardsIterator(T, .sequence) {
22812281
assert(delimiter.len != 0);
22822282
return .{
22832283
.index = buffer.len,
@@ -2295,9 +2295,9 @@ pub fn splitBackwardsFull(comptime T: type, buffer: []const T, delimiter: []cons
22952295
/// If none of `delimiters` exist in buffer,
22962296
/// the iterator will return `buffer`, null, in that order.
22972297
///
2298-
/// See also: `splitBackwardsFull`, `splitBackwardsScalar`,
2299-
/// `splitFull`, `splitAny`,`splitScalar`,
2300-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2298+
/// See also: `splitBackwardsSequence`, `splitBackwardsScalar`,
2299+
/// `splitSequence`, `splitAny`,`splitScalar`,
2300+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
23012301
pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitBackwardsIterator(T, .any) {
23022302
return .{
23032303
.index = buffer.len,
@@ -2315,9 +2315,9 @@ pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []cons
23152315
/// If `delimiter` does not exist in buffer,
23162316
/// the iterator will return `buffer`, null, in that order.
23172317
///
2318-
/// See also: `splitBackwardsFull`, `splitBackwardsAny`,
2319-
/// `splitFull`, `splitAny`,`splitScalar`,
2320-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2318+
/// See also: `splitBackwardsSequence`, `splitBackwardsAny`,
2319+
/// `splitSequence`, `splitAny`,`splitScalar`,
2320+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
23212321
pub fn splitBackwardsScalar(comptime T: type, buffer: []const T, delimiter: T) SplitBackwardsIterator(T, .scalar) {
23222322
return .{
23232323
.index = buffer.len,
@@ -2365,8 +2365,8 @@ test "splitBackwardsScalar" {
23652365
try testing.expect(it16.next() == null);
23662366
}
23672367

2368-
test "splitBackwardsFull (multibyte)" {
2369-
var it = splitBackwardsFull(u8, "a, b ,, c, d, e", ", ");
2368+
test "splitBackwardsSequence" {
2369+
var it = splitBackwardsSequence(u8, "a, b ,, c, d, e", ", ");
23702370
try testing.expectEqualSlices(u8, it.rest(), "a, b ,, c, d, e");
23712371
try testing.expectEqualSlices(u8, it.first(), "e");
23722372

@@ -2385,7 +2385,7 @@ test "splitBackwardsFull (multibyte)" {
23852385
try testing.expectEqualSlices(u8, it.rest(), "");
23862386
try testing.expect(it.next() == null);
23872387

2388-
var it16 = splitBackwardsFull(
2388+
var it16 = splitBackwardsSequence(
23892389
u16,
23902390
std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"),
23912391
std.unicode.utf8ToUtf16LeStringLiteral(", "),
@@ -2437,7 +2437,7 @@ test "splitBackwardsAny" {
24372437

24382438
test "splitBackwards (reset)" {
24392439
{
2440-
var it = splitBackwardsFull(u8, "abc def ghi", " ");
2440+
var it = splitBackwardsSequence(u8, "abc def ghi", " ");
24412441
try testing.expect(eql(u8, it.first(), "ghi"));
24422442
try testing.expect(eql(u8, it.next().?, "def"));
24432443
try testing.expect(eql(u8, it.next().?, "abc"));
@@ -2645,13 +2645,13 @@ test "endsWith" {
26452645
try testing.expect(!endsWith(u8, "Bob", "Bo"));
26462646
}
26472647

2648-
pub const DelimiterType = enum { full, any, scalar };
2648+
pub const DelimiterType = enum { sequence, any, scalar };
26492649

26502650
pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) type {
26512651
return struct {
26522652
buffer: []const T,
26532653
delimiter: switch (delimiter_type) {
2654-
.full, .any => []const T,
2654+
.sequence, .any => []const T,
26552655
.scalar => T,
26562656
},
26572657
index: usize,
@@ -2671,7 +2671,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
26712671
pub fn peek(self: *Self) ?[]const T {
26722672
// move to beginning of token
26732673
while (self.index < self.buffer.len and self.isDelimiter(self.index)) : (self.index += switch (delimiter_type) {
2674-
.full => self.delimiter.len,
2674+
.sequence => self.delimiter.len,
26752675
.any, .scalar => 1,
26762676
}) {}
26772677
const start = self.index;
@@ -2691,7 +2691,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
26912691
// move to beginning of token
26922692
var index: usize = self.index;
26932693
while (index < self.buffer.len and self.isDelimiter(index)) : (index += switch (delimiter_type) {
2694-
.full => self.delimiter.len,
2694+
.sequence => self.delimiter.len,
26952695
.any, .scalar => 1,
26962696
}) {}
26972697
return self.buffer[index..];
@@ -2704,7 +2704,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
27042704

27052705
fn isDelimiter(self: Self, index: usize) bool {
27062706
switch (delimiter_type) {
2707-
.full => return startsWith(T, self.buffer[index..], self.delimiter),
2707+
.sequence => return startsWith(T, self.buffer[index..], self.delimiter),
27082708
.any => {
27092709
const item = self.buffer[index];
27102710
for (self.delimiter) |delimiter_item| {
@@ -2725,7 +2725,7 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
27252725
buffer: []const T,
27262726
index: ?usize,
27272727
delimiter: switch (delimiter_type) {
2728-
.full, .any => []const T,
2728+
.sequence, .any => []const T,
27292729
.scalar => T,
27302730
},
27312731

@@ -2742,12 +2742,12 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
27422742
pub fn next(self: *Self) ?[]const T {
27432743
const start = self.index orelse return null;
27442744
const end = if (switch (delimiter_type) {
2745-
.full => indexOfPos(T, self.buffer, start, self.delimiter),
2745+
.sequence => indexOfPos(T, self.buffer, start, self.delimiter),
27462746
.any => indexOfAnyPos(T, self.buffer, start, self.delimiter),
27472747
.scalar => indexOfScalarPos(T, self.buffer, start, self.delimiter),
27482748
}) |delim_start| blk: {
27492749
self.index = delim_start + switch (delimiter_type) {
2750-
.full => self.delimiter.len,
2750+
.sequence => self.delimiter.len,
27512751
.any, .scalar => 1,
27522752
};
27532753
break :blk delim_start;
@@ -2777,7 +2777,7 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit
27772777
buffer: []const T,
27782778
index: ?usize,
27792779
delimiter: switch (delimiter_type) {
2780-
.full, .any => []const T,
2780+
.sequence, .any => []const T,
27812781
.scalar => T,
27822782
},
27832783

@@ -2794,13 +2794,13 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit
27942794
pub fn next(self: *Self) ?[]const T {
27952795
const end = self.index orelse return null;
27962796
const start = if (switch (delimiter_type) {
2797-
.full => lastIndexOf(T, self.buffer[0..end], self.delimiter),
2797+
.sequence => lastIndexOf(T, self.buffer[0..end], self.delimiter),
27982798
.any => lastIndexOfAny(T, self.buffer[0..end], self.delimiter),
27992799
.scalar => lastIndexOfScalar(T, self.buffer[0..end], self.delimiter),
28002800
}) |delim_start| blk: {
28012801
self.index = delim_start;
28022802
break :blk delim_start + switch (delimiter_type) {
2803-
.full => self.delimiter.len,
2803+
.sequence => self.delimiter.len,
28042804
.any, .scalar => 1,
28052805
};
28062806
} else blk: {

lib/std/zig/CrossTarget.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
706706
.linux,
707707
.dragonfly,
708708
=> {
709-
var range_it = mem.splitFull(u8, version_text, "...");
709+
var range_it = mem.splitSequence(u8, version_text, "...");
710710

711711
const min_text = range_it.next().?;
712712
const min_ver = SemVer.parse(min_text) catch |err| switch (err) {
@@ -726,7 +726,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
726726
},
727727

728728
.windows => {
729-
var range_it = mem.splitFull(u8, version_text, "...");
729+
var range_it = mem.splitSequence(u8, version_text, "...");
730730

731731
const min_text = range_it.first();
732732
const min_ver = std.meta.stringToEnum(Target.Os.WindowsVersion, min_text) orelse

src/Compilation.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5016,14 +5016,14 @@ fn parseLldStderr(comp: *Compilation, comptime prefix: []const u8, stderr: []con
50165016
defer context_lines.deinit();
50175017

50185018
var current_err: ?*LldError = null;
5019-
var lines = mem.splitFull(u8, stderr, std.cstr.line_sep);
5019+
var lines = mem.splitSequence(u8, stderr, std.cstr.line_sep);
50205020
while (lines.next()) |line| {
50215021
if (mem.startsWith(u8, line, prefix ++ ":")) {
50225022
if (current_err) |err| {
50235023
err.context_lines = try context_lines.toOwnedSlice();
50245024
}
50255025

5026-
var split = std.mem.splitFull(u8, line, "error: ");
5026+
var split = std.mem.splitSequence(u8, line, "error: ");
50275027
_ = split.first();
50285028

50295029
const duped_msg = try std.fmt.allocPrint(comp.gpa, "{s}: {s}", .{ prefix, split.rest() });

tools/update_crc_catalog.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn main() anyerror!void {
7878
var residue: []const u8 = undefined;
7979
var name: []const u8 = undefined;
8080

81-
var it = mem.splitFull(u8, line, " ");
81+
var it = mem.splitSequence(u8, line, " ");
8282
while (it.next()) |property| {
8383
const i = mem.indexOf(u8, property, "=").?;
8484
const key = property[0..i];

0 commit comments

Comments
 (0)