StringBuffer Module

The StringBuffer module allows a string to be built up by appending to the end of the StringBuffer. Just as in Java, C#, and other garbage collected languages, strings are immutable objects in Lua. The StringBuffer module should be used for building large strings by appending to the end of the StringBuffer instead of using string concatenation. Once the string has been built using the StringBuffer, it can be converted into a normal Lua string using the toString method of the StringBuffer object or using the standard Lua tostring function.

A StringBuffer can be used in place of a Lua string to return results back to the database. Returning a StringBuffer as a function result is more efficient than converting the StringBuffer into a string using tostring() or the :toString() method and then returning the resulting string.