java - Is chaining replaceFirst() calls inefficient for a chain of 51 calls? -


i'm working on template based code fills in placeholders chaining calls string.replacefirst() after collecting data replace placeholders line builds completed form.

string completedform = template.replacefirst("account_number",account_number).template.replacefirst("customer_id",customer_id)... 49 more in  chain 

i'm wondering if approach unecessarily costly because creates 51 string objects in course of building completedform.

is best way efficiency point of view?

it may efficient way. unless know performance problem wouldn't try guessing might , put in more complicated might not make difference in end.

if want code faster, suggest profile first profiler , work on things suggests spending time on.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -