code: public BinaryString trimRight(BinaryString trimStr) {
  		ensureMaterialized();
  		if (trimStr == null) {
  			return null;
  		}
  		trimStr.ensureMaterialized();
  		if (trimStr.isSpaceString()) {
  			return trimRight();
  		}
  		if (inFirstSegment()) {
  			int charIdx = 0;
  			int byteIdx = 0;
  			// each element in charLens is length of character in the source string
  			int[] charLens = new int[sizeInBytes];
  			// each element in charStartPos is start position of first byte in the source string
  			int[] charStartPos = new int[sizeInBytes];
  			while (byteIdx < sizeInBytes) {
  				charStartPos[charIdx] = byteIdx;
  				charLens[charIdx] = numBytesForFirstByte(getByteOneSegment(byteIdx));
  				byteIdx += charLens[charIdx];
  				charIdx++;
  			}
  			// searchIdx points to the first character which is not in trim string from the right
  			// end.
  			int searchIdx = sizeInBytes - 1;
  			charIdx -= 1;
  			while (charIdx >= 0) {
  				BinaryString currentChar = copyBinaryStringInOneSeg(
  					charStartPos[charIdx],
  					charStartPos[charIdx] + charLens[charIdx] - 1);
  				if (trimStr.contains(currentChar)) {
  					searchIdx -= charLens[charIdx];
  				} else {
  					break;
  				}
  				charIdx--;
  			}
  			if (searchIdx < 0) {
  				// empty string
  				return EMPTY_UTF8;
  			} else {
  				return copyBinaryStringInOneSeg(0, searchIdx);
  			}
  		} else {
  			return trimRightSlow(trimStr);
  		}
  	}
docs: Walk each character of current string from right end, remove the character if it
  is in trim string. Stops at the first character which is not in trim string.
  Return the new substring.
  
  @param trimStr the trim string
  @return A subString which removes all of the character from the right side that is in
  trim string.