多层循环直接跳出最外层循环

BoringLayout.java 中的代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
outer:
for (int start = 0; start < textLength; start += MAX_BUF_LEN) {
final int end = Math.min(start + MAX_BUF_LEN, textLength);
// No need to worry about getting half codepoints, since we reject surrogate code units
// as non-boring as soon we see one.
TextUtils.getChars(text, start, end, buffer, 0);
final int len = end - start;
for (int i = 0; i < len; i++) {
final char c = buffer[i];
if (c == '\n' || c == '\t' ||
(c >= 0x0590 && c <= 0x08FF) || // RTL scripts
c == 0x200F || // Bidi format character
(c >= 0x202A && c <= 0x202E) || // Bidi format characters
(c >= 0x2066 && c <= 0x2069) || // Bidi format characters
(c >= 0xD800 && c <= 0xDFFF) || // surrogate pairs
(c >= 0xFB1D && c <= 0xFDFF) || // Hebrew and Arabic presentation forms
(c >= 0xFE70 && c <= 0xFEFE) // Arabic presentation forms
) {
boring = false;
break outer;
}
}
// TODO: This looks a little suspicious, and in some cases can result in O(n^2)
// run time. Consider moving outside the loop.
if (textDir != null && textDir.isRtl(buffer, 0, len)) {
boring = false;
break outer;
}
}