MCPcopy Index your code
hub / github.com/antlr/codebuff / length

Method length

output/java_guava/1.4.17/CharSource.java:160–175  ·  view source on GitHub ↗

Returns the length of this source in chars, even if doing so requires opening and traversing an entire stream. To avoid a potentially expensive operation, see #lengthIfKnown. The default implementation calls #lengthIfKnown and returns the value if present. If absent, it will fall

()

Source from the content-addressed store, hash-verified

158 */
159
160 @Beta
161 public long length() throws IOException {
162 Optional<Long> lengthIfKnown = lengthIfKnown();
163 if (lengthIfKnown.isPresent()) {
164 return lengthIfKnown.get();
165 }
166 Closer closer = Closer.create();
167 try {
168 Reader reader = closer.register(openStream());
169 return countBySkipping(reader);
170 } catch (Throwable e) {
171 throw closer.rethrow(e);
172 } finally {
173 closer.close();
174 }
175 }
176
177 private long countBySkipping(Reader reader) throws IOException {
178 long count = 0;

Callers 15

writeMethod · 0.45
appendMethod · 0.45
putUnencodedCharsMethod · 0.45
joinMethod · 0.45
joinMethod · 0.45
toStringMethod · 0.45
escapeMethod · 0.45
hashUnencodedCharsMethod · 0.45
tryParseMethod · 0.45
decodeCheckedMethod · 0.45
canDecodeMethod · 0.45

Calls 9

lengthIfKnownMethod · 0.95
createMethod · 0.95
registerMethod · 0.95
openStreamMethod · 0.95
countBySkippingMethod · 0.95
rethrowMethod · 0.95
closeMethod · 0.95
getMethod · 0.65
isPresentMethod · 0.45

Tested by

no test coverage detected