@@ -346,15 +346,22 @@ isless(a::Symbol, b::Symbol) = cmp(a, b) < 0
346
346
length(s::AbstractString) -> Int
347
347
length(s::AbstractString, i::Integer, j::Integer) -> Int
348
348
349
- The number of characters in string `s` from indices `i` through `j`. This is
350
- computed as the number of code unit indices from `i` to `j` which are valid
351
- character indices. With only a single string argument, this computes the
352
- number of characters in the entire string. With `i` and `j` arguments it
349
+ Return the number of characters in string `s` from indices `i` through `j`.
350
+
351
+ This is computed as the number of code unit indices from `i` to `j` which are
352
+ valid character indices. With only a single string argument, this computes
353
+ the number of characters in the entire string. With `i` and `j` arguments it
353
354
computes the number of indices between `i` and `j` inclusive that are valid
354
355
indices in the string `s`. In addition to in-bounds values, `i` may take the
355
356
out-of-bounds value `ncodeunits(s) + 1` and `j` may take the out-of-bounds
356
357
value `0`.
357
358
359
+ !!! note
360
+ The time complexity of this operation is linear in general. That is, it
361
+ will take the time proportional to the number of bytes or characters in
362
+ the string because it counts the value on the fly. This is in contrast to
363
+ the method for arrays, which is a constant-time operation.
364
+
358
365
See also: [`isvalid`](@ref), [`ncodeunits`](@ref), [`lastindex`](@ref),
359
366
[`thisind`](@ref), [`nextind`](@ref), [`prevind`](@ref)
360
367
0 commit comments