提交 c3318f29 编写于 作者: K Kevin Cantu 提交者: Marijn Haverbeke

(core::str) rename substr_len_bytes to substr_len, and delete unused byte_index[_from]

上级 7782f5d6
......@@ -171,7 +171,7 @@ fn lookup_byte_offset(cm: codemap::codemap, chpos: uint)
let {fm,line} = lookup_line(cm,chpos,lookup);
let line_offset = fm.lines[line].byte - fm.start_pos.byte;
let col = chpos - fm.lines[line].ch;
let col_offset = str::substr_len_bytes(*fm.src, line_offset, col);
let col_offset = str::substr_len(*fm.src, line_offset, col);
ret {fm: fm, pos: line_offset + col_offset};
}
......
......@@ -93,7 +93,7 @@
// Misc
// FIXME: perhaps some more of this section shouldn't be exported?
is_utf8,
substr_len_bytes,
substr_len,
substr_len_chars,
utf8_char_width,
char_range_at,
......@@ -914,27 +914,6 @@ fn index_chars(ss: str, cc: char) -> option<uint> {
ret none;
}
// Function: byte_index
//
// Returns the index of the first matching byte
// (as option some/none)
// FIXME: delete
fn byte_index(s: str, b: u8) -> option<uint> {
byte_index_from(s, b, 0u, len(s))
}
// Function: byte_index_from
//
// Returns the index of the first matching byte within the range [`start`,
// `end`).
// (as option some/none)
// FIXME: delete
fn byte_index_from(s: str, b: u8, start: uint, end: uint) -> option<uint> {
assert end <= len(s);
str::as_bytes(s) { |v| vec::position_from(v, start, end) { |x| x == b } }
}
// Function: rindex
//
// Returns the byte index of the first matching char
......
......@@ -795,7 +795,7 @@ fn of_substr_unsafer(str: @str, byte_start: uint, byte_len: uint,
if i == 0u { first_leaf_char_len }
else { hint_max_leaf_char_len };
let chunk_byte_len =
str::substr_len_bytes(*str, offset, chunk_char_len);
str::substr_len(*str, offset, chunk_char_len);
nodes[i] = @leaf({
byte_offset: offset,
byte_len: chunk_byte_len,
......@@ -1059,9 +1059,9 @@ fn sub_chars(node: @node, char_offset: uint, char_len: uint) -> @node {
ret node;
}
let byte_offset =
str::substr_len_bytes(*x.content, 0u, char_offset);
str::substr_len(*x.content, 0u, char_offset);
let byte_len =
str::substr_len_bytes(*x.content, byte_offset, char_len);
str::substr_len(*x.content, byte_offset, char_len);
ret @leaf({byte_offset: byte_offset,
byte_len: byte_len,
char_len: char_len,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册