Performance: limit use of txtbuf.insert()