(void)locale;// TODO: Support locale-sensitive boundaries
// 4. If direction is before, then
if(direction==Direction::Before){
// a. Assert: startIndex ≥ 0.
VERIFY(start_index>=0);
// b. Assert: startIndex < len.
VERIFY(start_index<length);
// c. Search string for the last segmentation boundary that is preceded by at most startIndex code units from the beginning, using locale locale and text element granularity granularity.
// d. If a boundary is found, return the count of code units in string preceding it.
if(boundary_index<boundaries_cache->size())
returnboundaries_cache->at(boundary_index);
// e. Return 0.
return0;
}
// 5. Assert: direction is after.
VERIFY(direction==Direction::After);
// 6. If len is 0 or startIndex ≥ len, return +∞.
if(length==0||start_index>=length)
returnINFINITY;
// 7. Search string for the first segmentation boundary that follows the code unit at index startIndex, using locale locale and text element granularity granularity.