MCPcopy Create free account
hub / github.com/acl-dev/acl / serialize

Method serialize

lib_acl_cpp/samples/benchmark/json/jtjson/json.cpp:716–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

714}
715
716void
717Json::serialize(std::string& sb, const JTJSON_STRING_VIEW& s)
718{
719 size_t i, j, m;
720 wint_t x, a, b;
721 unsigned long long w;
722 for (i = 0; i < s.size();) {
723 x = s[i++] & 255;
724 if (x >= 0300) {
725 a = ThomPikeByte(x);
726 m = ThomPikeLen(x) - 1;
727 if (i + m <= s.size()) {
728 for (j = 0;;) {
729 b = s[i + j] & 0xff;
730 if (!ThomPikeCont(b))
731 break;
732 a = ThomPikeMerge(a, b);
733 if (++j == m) {
734 x = a;
735 i += j;
736 break;
737 }
738 }
739 }
740 }
741 switch (0 < x && x <= 127 ? kEscapeLiteral[x] : 9) {
742 case 0:
743 sb += x;
744 break;
745 case 1:
746 sb += "\\t";
747 break;
748 case 2:
749 sb += "\\n";
750 break;
751 case 3:
752 sb += "\\r";
753 break;
754 case 4:
755 sb += "\\f";
756 break;
757 case 5:
758 sb += "\\\\";
759 break;
760 case 6:
761 sb += "\\/";
762 break;
763 case 7:
764 sb += "\\\"";
765 break;
766 case 9:
767 w = EncodeUtf16(x);
768 do {
769 char esc[6];
770 esc[0] = '\\';
771 esc[1] = 'u';
772 esc[2] = "0123456789abcdef"[(w & 0xF000) >> 014];
773 esc[3] = "0123456789abcdef"[(w & 0x0F00) >> 010];

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected