Skip to content

Commit 4e2cde5

Browse files
killerswanmarijnh
authored andcommitted
---
yaml --- r: 11445 b: refs/heads/master c: c2984b4 h: refs/heads/master i: 11443: ffee069 v: v3
1 parent 70d6d7c commit 4e2cde5

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 961b6446b6123616b6f0b935813021e43da3ef18
2+
refs/heads/master: c2984b46b4c3b8b91d877ebc85efcc9f783c53d5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/str.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Module: str
44
String manipulation
55
66
Strings are a packed UTF-8 representation of text, stored as null terminated
7-
buffers of u8 bytes. Strings should be considered by character,
8-
for correctness, but some UTF-8 unsafe functions are also provided.
9-
For some heavy-duty uses, we recommend trying std::rope.
7+
buffers of u8 bytes. Strings should be indexed in bytes, for efficiency,
8+
but UTF-8 unsafe operations should be avoided.
9+
For some heavy-duty uses, try std::rope.
1010
*/
1111

1212
import option::{some, none};
@@ -434,6 +434,7 @@ Failure:
434434
- If end is greater than the character length of the string
435435
436436
FIXME: make faster by avoiding char conversion
437+
FIXME: delete?
437438
*/
438439
fn slice_chars(s: str, begin: uint, end: uint) -> str {
439440
from_chars(vec::slice(chars(s), begin, end))
@@ -498,7 +499,7 @@ Splits a string into a vector of the substrings separated by a given string
498499
Note that this has recently been changed. For example:
499500
> assert ["", "XXX", "YYY", ""] == split_str(".XXX.YYY.", ".")
500501
501-
FIXME: Boyer-Moore variation
502+
FIXME: Boyer-Moore should be faster
502503
*/
503504
fn split_str(ss: str, sep: str) -> [str] unsafe {
504505
// unsafe is justified: we are splitting
@@ -670,7 +671,7 @@ fn to_upper(s: str) -> str {
670671
map(s, char::to_upper)
671672
}
672673

673-
// FIXME: This is super-inefficient
674+
// FIXME: This is super-inefficient: stop the extra slicing copies
674675
/*
675676
Function: replace
676677
@@ -894,6 +895,7 @@ fn index_from(ss: str, cc: char, start: uint, end: uint) -> option<uint> {
894895
//
895896
// Returns the char index of the first matching char
896897
// (as option some/none)
898+
// FIXME: delete?
897899
fn index_chars(ss: str, cc: char) -> option<uint> {
898900
let bii = 0u;
899901
let cii = 0u;
@@ -938,6 +940,7 @@ fn rindex(ss: str, cc: char) -> option<uint> {
938940
//
939941
// Returns the char index of the first matching char
940942
// (as option some/none)
943+
// FIXME: delete?
941944
fn rindex_chars(ss: str, cc: char) -> option<uint> {
942945
let bii = len(ss);
943946
let cii = len_chars(ss);
@@ -998,6 +1001,7 @@ fn find_from(haystack: str, needle: str, start: uint, end:uint)
9981001
//
9991002
// Find the char position of the first instance of one string
10001003
// within another, or return option::none
1004+
// FIXME: delete?
10011005
fn find_chars(haystack: str, needle: str) -> option<uint> {
10021006
alt find(haystack, needle) {
10031007
none { ret none; }
@@ -1065,8 +1069,8 @@ haystack - The string to look in
10651069
needle - The string to look for
10661070
*/
10671071
fn ends_with(haystack: str, needle: str) -> bool {
1068-
let haystack_len: uint = len_chars(haystack);
1069-
let needle_len: uint = len_chars(needle);
1072+
let haystack_len: uint = len(haystack);
1073+
let needle_len: uint = len(needle);
10701074
ret if needle_len == 0u {
10711075
true
10721076
} else if needle_len > haystack_len {
@@ -1129,6 +1133,7 @@ pure fn len(s: str) -> uint unsafe {
11291133
}
11301134
}
11311135

1136+
// FIXME: delete?
11321137
fn len_chars(s: str) -> uint {
11331138
substr_len_chars(s, 0u, len(s))
11341139
}
@@ -1177,6 +1182,8 @@ Safety note:
11771182
- This function does not check whether the substring is valid.
11781183
- This function fails if `byte_offset` or `byte_len` do not
11791184
represent valid positions inside `s`
1185+
1186+
FIXME: delete?
11801187
*/
11811188
fn substr_len_chars(s: str, byte_start: uint, byte_len: uint) -> uint {
11821189
let i = byte_start;
@@ -1451,12 +1458,13 @@ fn reserve(&ss: str, nn: uint) {
14511458
// These functions may create invalid UTF-8 strings and eat your baby.
14521459
mod unsafe {
14531460
export
1461+
// FIXME: stop exporting several of these
14541462
from_bytes,
14551463
from_byte,
1456-
slice_bytes, // FIXME: stop exporting
1457-
slice_bytes_safe_range, // FIXME: stop exporting
1464+
slice_bytes,
1465+
slice_bytes_safe_range,
14581466
push_byte,
1459-
push_bytes, // note: wasn't exported
1467+
push_bytes,
14601468
pop_byte,
14611469
shift_byte;
14621470

@@ -1489,7 +1497,6 @@ mod unsafe {
14891497
- If end is greater than the length of the string.
14901498
*/
14911499
unsafe fn slice_bytes(s: str, begin: uint, end: uint) -> str unsafe {
1492-
// FIXME: Typestate precondition
14931500
assert (begin <= end);
14941501
assert (end <= len(s));
14951502

0 commit comments

Comments
 (0)