[refactoring] Refactored TextDocument for using StringBuilder instead of String. These approach could be faster in some cases.