MCPcopy Create free account
hub / github.com/Card-Forge/forge / fastReplace

Method fastReplace

forge-core/src/main/java/forge/util/TextUtil.java:299–321  ·  view source on GitHub ↗
( String str, String target, String replacement )

Source from the content-addressed store, hash-verified

297
298 //fast Replace
299 public static String fastReplace( String str, String target, String replacement ) {
300 if (str == null) {
301 return null;
302 }
303 int targetLength = target.length();
304 if( targetLength == 0 ) {
305 return str;
306 }
307 int idx2 = str.indexOf( target );
308 if( idx2 < 0 ) {
309 return str;
310 }
311 StringBuilder sb = new StringBuilder( targetLength > replacement.length() ? str.length() : str.length() * 2 );
312 int idx1 = 0;
313 do {
314 sb.append( str, idx1, idx2 );
315 sb.append( replacement );
316 idx1 = idx2 + targetLength;
317 idx2 = str.indexOf( target, idx1 );
318 } while( idx2 > 0 );
319 sb.append( str, idx1, str.length() );
320 return sb.toString();
321 }
322 //Convert to Mana String
323 public static String toManaString(String ManaProduced) {
324 if ("mana".equals(ManaProduced) || ManaProduced.contains("Combo")|| ManaProduced.contains("Any"))

Callers 15

executeScriptMethod · 0.95
visitMethod · 0.95
notifyOfValueMethod · 0.95
executeReplacementMethod · 0.95
getDescriptionMethod · 0.95
toStringMethod · 0.95
toStringMethod · 0.95
replaceAbilityTextMethod · 0.95
canPayMethod · 0.95
canPayMethod · 0.95
canPayMethod · 0.95

Calls 4

lengthMethod · 0.80
indexOfMethod · 0.65
appendMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected