{"id":118384,"date":"2026-10-27T03:16:21","date_gmt":"2026-10-26T19:16:21","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/118384.html"},"modified":"2026-10-27T03:16:21","modified_gmt":"2026-10-26T19:16:21","slug":"08-01-%e4%bc%98%e5%8c%96-%e5%ad%97%e7%ac%a6%e4%b8%b2%e4%b8%8e%e6%96%87%e6%9c%ac%e6%93%8d%e4%bd%9c%e7%9a%84gc%e9%99%b7%e9%98%b1","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/118384.html","title":{"rendered":"08-01-\u4f18\u5316-\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684GC\u9677\u9631"},"content":{"rendered":"<h2 id=\"\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684-gc-\u9677\u9631\">\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684 GC \u9677\u9631<\/h2>\n<p>\u7bc7\u7ae0&#xff1a;08-\u6027\u80fd\u4f18\u5316\u7bc7 |\u00a0\u9605\u8bfb\u65f6\u95f4&#xff1a;\u7ea6 45 \u5206\u949f |\u00a0\u524d\u7f6e\u77e5\u8bc6&#xff1a;\u4e86\u89e3 C# \u5b57\u7b26\u4e32\u57fa\u672c\u64cd\u4f5c\u4e0e Unity Profiler \u7684 GC.Alloc \u7528\u6cd5<\/p>\n<hr \/>\n<h3 id=\"\u4e00-\u5f15\u8a00\">\u4e00\u3001\u5f15\u8a00<\/h3>\n<p>\u5b57\u7b26\u4e32\u64cd\u4f5c\u662f C# \u7a0b\u5e8f\u4e2d\u6700\u5e38\u89c1\u7684 GC \u5206\u914d\u6765\u6e90\u3002\u5b57\u7b26\u4e32\u7684\u4e0d\u53ef\u53d8\u6027\u5bfc\u81f4\u6bcf\u6b21&#034;\u4fee\u6539&#034;\u90fd\u521b\u5efa\u65b0\u5bf9\u8c61\u3002\u8fd9\u4e00\u6761\u51e0\u4e4e\u6bcf\u4e2a C# \u5f00\u53d1\u8005\u90fd\u80cc\u5f97\u51fa&#xff0c;\u4f46\u5728 Unity \u9879\u76ee\u91cc&#xff0c;\u5b83\u771f\u6b63\u54ac\u4eba\u7684\u5730\u65b9\u8fdc\u4e0d\u6b62&#034;\u62fc\u63a5\u4ea7\u751f\u65b0\u5b57\u7b26\u4e32&#034;\u8fd9\u4e00\u53e5\u8bdd&#xff1a;\u63d2\u503c\u5b57\u7b26\u4e32\u80cc\u540e\u7684\u88c5\u7bb1\u3001Substring \u7684\u6574\u6bb5\u590d\u5236\u3001\u6bcf\u6b21 ToString \u7684\u4e34\u65f6\u5bf9\u8c61\u3001UTF8 \u7f16\u7801\u5f80\u8fd4\u65f6\u6210\u500d\u7684\u5b57\u8282\u5206\u914d\u3001UI \u6bcf\u5e27\u6539\u6587\u672c\u5f15\u53d1\u7684\u8fde\u9501\u91cd\u5efa&#xff0c;\u8fd9\u4e9b\u5206\u914d\u70b9\u5355\u72ec\u770b\u90fd\u4e0d\u5927&#xff0c;\u53e0\u5728\u6bcf\u5e27\u6267\u884c\u7684\u70ed\u8def\u5f84\u4e0a\u5c31\u662f GC \u5361\u987f\u7684\u4e3b\u529b\u3002<\/p>\n<p>\u672c\u6587\u7684\u76ee\u6807\u5f88\u5177\u4f53&#xff1a;\u628a\u5b57\u7b26\u4e32\u76f8\u5173\u7684\u5206\u914d\u9677\u9631\u9010\u4e2a\u62c6\u5f00&#xff0c;\u6bcf\u4e2a\u9677\u9631\u90fd\u6309&#034;\u73b0\u8c61 \u2192 \u5206\u914d\u5728\u54ea\u4ea7\u751f \u2192 \u91cf\u7ea7\u4f30\u7b97 \u2192 \u6539\u6cd5&#034;\u56db\u6b65\u8bb2\u6e05\u695a&#xff0c;\u8bfb\u5b8c\u4e4b\u540e\u4f60\u53ef\u4ee5\u76f4\u63a5\u62ff\u7740\u6e05\u5355\u53bb\u6539\u81ea\u5df1\u7684\u9879\u76ee\u3002\u5168\u6587\u6309\u8fd9\u4e2a\u987a\u5e8f\u5c55\u5f00&#xff1a;\u7b2c\u4e8c\u8282\u8bb2\u4e0d\u53ef\u53d8\u6027\u4e3a\u4ec0\u4e48\u8ba9\u5b57\u7b26\u4e32\u6210\u4e3a\u5206\u914d\u5927\u6237&#xff1b;\u7b2c\u4e09\u5230\u7b2c\u4e94\u8282\u4f9d\u6b21\u62c6\u62fc\u63a5\u3001Substring\u3001ToString \u4e0e\u88c5\u7bb1&#xff1b;\u7b2c\u516d\u8282\u8bb2 StringBuilder \u7684\u6b63\u786e\u7528\u6cd5\u4e0e\u8bef\u7528&#xff1b;\u7b2c\u4e03\u3001\u516b\u8282\u8986\u76d6\u5b57\u7b26\u4e32\u6c60\u5316\u4e0e\u7f16\u7801\u8f6c\u6362&#xff1b;\u7b2c\u4e5d\u8282\u5355\u72ec\u8c08 TextMeshPro \u7684\u5e38\u89c1\u8bef\u7528&#xff1b;\u6700\u540e\u4e09\u8282\u7ed9\u51fa\u91cf\u7ea7\u4f30\u7b97\u8868\u3001\u8bef\u533a\u6e05\u5355\u4e0e\u5de5\u7a0b\u51b3\u7b56\u6e05\u5355\u3002<\/p>\n<p>\u9700\u8981\u5148\u8bf4\u6e05\u695a\u53e3\u5f84&#xff1a;\u672c\u6587\u6240\u6709\u5b57\u8282\u6570\u90fd\u662f\u5178\u578b\u4f30\u7b97\u6216\u793a\u4f8b\u91cf\u7ea7&#xff0c;\u4e0d\u662f\u4efb\u4f55\u673a\u578b\u4e0a\u7684\u5b9e\u6d4b\u5e38\u6570\u3002\u5206\u914d\u91cf\u53d6\u51b3\u4e8e\u5b57\u7b26\u4e32\u957f\u5ea6\u3001\u8fd0\u884c\u65f6\u7248\u672c\u4e0e\u540e\u7aef&#xff08;Mono \u4e0e IL2CPP \u7684\u5b57\u7b26\u4e32\u5e03\u5c40\u7ec6\u8282\u5e76\u4e0d\u5b8c\u5168\u4e00\u81f4&#xff09;&#xff0c;\u552f\u4e00\u53ef\u9760\u7684\u9a8c\u6536\u65b9\u5f0f\u662f\u8fde\u771f\u673a Profiler \u770b GC Allocated In Frame \u8ba1\u6570\u5668\u3002<\/p>\n<h3 id=\"\u4e8c-\u5b57\u7b26\u4e32\u4e3a\u4ec0\u4e48\u5929\u751f\u662f\u5206\u914d\u5927\u6237\">\u4e8c\u3001\u5b57\u7b26\u4e32\u4e3a\u4ec0\u4e48\u5929\u751f\u662f\u5206\u914d\u5927\u6237<\/h3>\n<h4 id=\"21-\u4e0d\u53ef\u53d8\u6027\u4e0e\u5bf9\u8c61\u5e03\u5c40\">2.1 \u4e0d\u53ef\u53d8\u6027\u4e0e\u5bf9\u8c61\u5e03\u5c40<\/h4>\n<p>C# \u7684 string \u662f\u4e0d\u53ef\u53d8\u7c7b\u578b&#xff1a;\u5bf9\u8c61\u4e00\u65e6\u521b\u5efa&#xff0c;\u5b57\u7b26\u5185\u5bb9\u4e0d\u80fd\u518d\u6539\u3002\u6240\u8c13&#034;\u4fee\u6539&#034;\u5b57\u7b26\u4e32&#xff0c;\u672c\u8d28\u4e0a\u90fd\u662f&#034;\u65b0\u5efa\u4e00\u4e2a\u5b57\u7b26\u4e32&#xff0c;\u628a\u65e7\u5185\u5bb9\u548c\u65b0\u5185\u5bb9\u62fc\u8fdb\u53bb&#xff0c;\u65e7\u7684\u4e22\u7ed9 GC&#034;\u3002\u4ece\u5185\u5b58\u5e03\u5c40\u4e0a\u770b&#xff0c;\u4e00\u4e2a string \u5bf9\u8c61\u5927\u81f4\u662f\u8fd9\u6837\u5360\u7528\u5806\u7a7a\u95f4\u7684&#xff1a;<\/p>\n<p>string s &#061; &#034;HP:1234\/9999&#034;;   \/\/ 14 \u4e2a\u5b57\u7b26&#xff08;\u793a\u4f8b&#xff09;<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u5bf9\u8c61\u5934&#xff08;\u540c\u6b65\u5757\u7d22\u5f15 &#043; \u65b9\u6cd5\u8868\u6307\u9488&#xff0c;8~16B \u91cf\u7ea7&#xff09; \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u957f\u5ea6\u5b57\u6bb5 length&#xff08;4B&#xff09;                          \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u5b57\u7b26\u6570\u636e&#xff08;UTF-16&#xff0c;\u6bcf\u5b57\u7b26 2B&#xff09;                  \u2502<br \/>\n\u2502  &#039;H&#039; &#039;P&#039; &#039;:&#039; &#039;1&#039; &#039;2&#039; &#039;3&#039; &#039;4&#039; &#039;\/&#039; &#8230;          \u2502<br \/>\n\u2502  \u5171 14 \u00d7 2B &#061; 28B&#xff08;\u5178\u578b\u4f30\u7b97&#xff09;                  \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n\u5bf9\u8c61\u603b\u5927\u5c0f \u2248 \u5bf9\u8c61\u5934 &#043; 4B &#043; 2\u00d7\u5b57\u7b26\u6570&#xff0c;\u518d\u5bf9\u9f50\u5230\u6307\u9488\u5bbd\u5ea6<\/p>\n<p>\u8fd9\u5f20\u56fe\u89e3\u91ca\u4e86\u4e24\u4e2a\u540e\u9762\u53cd\u590d\u7528\u5230\u7684\u4e8b\u5b9e\u3002\u7b2c\u4e00&#xff0c;\u5b57\u7b26\u4e32\u7684\u5185\u5b58\u5f00\u9500\u548c\u5b57\u7b26\u6570\u7ebf\u6027\u76f8\u5173&#xff0c;\u4e00\u4e2a 500 \u5b57\u7b26\u7684\u957f\u6587\u672c\u5bf9\u8c61\u5c31\u662f 1KB \u4e0a\u4e0b&#xff08;\u5178\u578b\u4f30\u7b97&#xff09;&#xff0c;\u5207\u5b83\u4e00\u5c0f\u6bb5\u5e76\u4e0d\u4f1a\u81ea\u52a8\u53d8\u5c0f\u3002\u7b2c\u4e8c&#xff0c;\u6bcf\u6b21&#034;\u4fee\u6539&#034;\u90fd\u4f1a\u5b8c\u6574\u590d\u5236\u4e00\u904d\u5b57\u7b26\u6570\u636e&#xff0c;\u5b57\u7b26\u8d8a\u591a\u5355\u6b21\u5206\u914d\u8d8a\u8d35\u3002\u5206\u914d\u672c\u8eab\u8fd8\u6ca1\u5b8c&#xff0c;Unity \u9ed8\u8ba4\u7684 Boehm \u6536\u96c6\u5668\u4e0d\u538b\u7f29\u3001\u4e0d\u79fb\u52a8\u5bf9\u8c61&#xff0c;\u8fd9\u4e9b\u77ed\u547d\u5b57\u7b26\u4e32\u5728\u5806\u91cc\u7559\u4e0b\u7684\u662f\u5b9e\u6253\u5b9e\u7684\u7a7a\u6d1e&#xff0c;\u957f\u671f\u8fd0\u884c\u540e\u788e\u7247\u6301\u7eed\u7d2f\u79ef&#xff08;\u673a\u5236\u7ec6\u8282\u53c2\u89c1\u672c\u4e13\u680f 03 \u7bc7\u4e0e 06 \u7bc7&#xff09;\u3002<\/p>\n<h4 id=\"22-\u4e00\u6b21\u4fee\u6539\u4ea7\u751f\u591a\u5c11\u5783\u573e\">2.2 \u4e00\u6b21&#034;\u4fee\u6539&#034;\u4ea7\u751f\u591a\u5c11\u5783\u573e<\/h4>\n<p>\u628a\u4e00\u6b21\u770b\u4f3c\u65e0\u5bb3\u7684\u5b57\u7b26\u4e32\u66f4\u65b0\u653e\u5230\u65f6\u95f4\u7ebf\u4e0a\u770b&#xff0c;\u5206\u914d\u662f\u6210\u4e32\u51fa\u73b0\u7684&#xff1a;<\/p>\n<p>\u4ee3\u7801&#xff1a; msg &#061; &#034;HP:&#034; &#043; hp &#043; &#034;\/&#034; &#043; max;      \/\/ hp\u3001max \u4e3a int<\/p>\n<p>\u6267\u884c\u671f\u5b9e\u9645\u53d1\u751f\u7684\u4e8b&#xff08;\u793a\u610f&#xff09;&#xff1a;<br \/>\n  int.ToString(hp)        \u2192 \u65b0\u5b57\u7b26\u4e32 &#034;1234&#034;          [\u5206\u914d 1]<br \/>\n  int.ToString(max)       \u2192 \u65b0\u5b57\u7b26\u4e32 &#034;9999&#034;          [\u5206\u914d 2]<br \/>\n  string.Concat(&#8230;)      \u2192 \u4e34\u65f6\u4e32 &#034;HP:1234&#034;         [\u5206\u914d 3]<br \/>\n  string.Concat(&#8230;)      \u2192 \u6700\u7ec8\u4e32 &#034;HP:1234\/9999&#034;    [\u5206\u914d 4]<br \/>\n                            \u65e7 msg \u53d8\u6210\u5783\u573e&#xff08;\u5982\u679c\u5b83\u8fd8\u6709\u5f15\u7528\u5c31\u5148\u6d3b\u7740&#xff09;<\/p>\n<p>\u4e00\u5e27\u91cc\u5982\u679c 200 \u4e2a\u8840\u6761\u90fd\u5728\u505a\u8fd9\u4ef6\u4e8b&#xff1a;<br \/>\n  200 \u00d7 4 \u4e2a\u77ed\u547d\u5b57\u7b26\u4e32 \u2248 800 \u4e2a\u5bf9\u8c61\u8fdb\u5165\u5806&#xff0c;\u7b49\u5f85\u4e0b\u4e00\u8f6e GC \u6e05\u7406<\/p>\n<p>\u5355\u4e2a\u77ed\u5b57\u7b26\u4e32\u7684\u5206\u914d\u4e0e\u56de\u6536\u5f88\u5feb&#xff0c;\u95ee\u9898\u51fa\u5728\u9891\u7387\u3002\u6e38\u620f\u91cc\u8840\u91cf\u3001\u5f39\u836f\u3001\u8ba1\u65f6\u5668\u3001\u4f24\u5bb3\u98d8\u5b57\u3001\u6218\u6597\u65e5\u5fd7&#xff0c;\u5168\u90fd\u5728\u6309\u5e27\u6216\u6309\u4e8b\u4ef6\u91cd\u590d\u8fd9\u5957\u52a8\u4f5c\u3002\u5206\u914d\u901f\u7387\u4e00\u9ad8&#xff0c;GC \u89e6\u53d1\u5c31\u4f1a\u53d8\u52e4&#xff0c;\u6bcf\u6b21\u6536\u96c6\u9762\u5bf9\u7684\u90fd\u662f\u4e00\u5927\u5806\u672c\u53ef\u4ee5\u4e0d\u5b58\u5728\u7684\u5783\u573e\u3002<\/p>\n<h4 id=\"23-\u5e38\u89c1\u8bef\u89e3\u5148\u7ea0\u6b63\u4e24\u6761\">2.3 \u5e38\u89c1\u8bef\u89e3\u5148\u7ea0\u6b63\u4e24\u6761<\/h4>\n<p>\u7b2c\u4e00\u6761\u8bef\u89e3\u662f&#034;\u6211\u7528\u7684\u90fd\u662f\u5e38\u91cf\u62fc\u63a5&#xff0c;\u7f16\u8bd1\u671f\u5c31\u5408\u5e76\u4e86&#034;\u3002\u53ea\u6709\u6bcf\u4e00\u9879\u5728\u7f16\u8bd1\u671f\u90fd\u662f\u5b57\u9762\u91cf\u5e38\u91cf\u65f6&#xff0c;\u7f16\u8bd1\u5668\u624d\u4f1a\u6298\u53e0\u6210\u4e00\u4e2a\u5e38\u91cf\u5b57\u7b26\u4e32&#xff0c;\u8fd0\u884c\u671f\u96f6\u5206\u914d\u3002\u53ea\u8981\u6709\u4e00\u9879\u6765\u81ea\u53d8\u91cf&#xff0c;\u6bd4\u5982\u00a0&#034;HP:&#034; &#043; hp&#xff0c;\u8fd0\u884c\u671f\u8be5\u505a\u7684\u5206\u914d\u4e00\u4e2a\u8dd1\u4e0d\u6389\u3002<\/p>\n<p>\u7b2c\u4e8c\u6761\u8bef\u89e3\u662f&#034;\u5c0f\u5b57\u7b26\u4e32\u6ca1\u51e0\u4e2a\u5b57\u8282&#xff0c;\u65e0\u6240\u8c13&#034;\u3002\u77ed\u547d\u5bf9\u8c61\u7684\u6210\u672c\u4e0d\u5728\u4e8e\u5b83\u5360\u591a\u5c11\u5b57\u8282&#xff0c;\u800c\u5728\u4e8e\u51fa\u73b0\u6b21\u6570\u4e58\u4ee5 GC \u626b\u63cf\u5b83\u7684\u6b21\u6570\u3002Boehm \u4e0d\u5206\u4ee3&#xff0c;\u6ca1\u6709\u65b0\u751f\u4ee3&#034;\u671d\u751f\u5915\u6b7b\u5feb\u901f\u56de\u6536&#034;\u7684\u7f13\u51b2\u533a\u3002\u5bf9 Unity \u9879\u76ee\u6765\u8bf4&#xff0c;\u628a\u6bcf\u5e27 KB \u7ea7\u7684\u5b57\u7b26\u4e32\u5206\u914d\u538b\u4e0b\u53bb&#xff0c;\u6536\u76ca\u901a\u5e38\u5927\u4e8e\u628a\u67d0\u4e2a\u5927\u6570\u7ec4\u7f29\u5c0f\u4e00\u534a\u3002<\/p>\n<h3 id=\"\u4e09-\u62fc\u63a5-stringconcat--\u4e0e\u5faa\u73af\u62fc\u63a5\">\u4e09\u3001\u62fc\u63a5&#xff1a;&#043;\u3001string.Concat\u3001$&#034;&#034;\u00a0\u4e0e\u5faa\u73af\u62fc\u63a5<\/h3>\n<h4 id=\"31-\u7f16\u8bd1\u5668\u628a\u8fd9\u4e9b\u5199\u6cd5\u964d\u7ea7\u6210\u4ec0\u4e48\">3.1 \u7f16\u8bd1\u5668\u628a\u8fd9\u4e9b\u5199\u6cd5\u964d\u7ea7\u6210\u4ec0\u4e48<\/h4>\n<p>\u5148\u770b\u6e05\u695a\u6bcf\u79cd\u62fc\u63a5\u5199\u6cd5\u5728 IL \u5c42\u9762\u843d\u5230\u54ea\u4e2a\u8c03\u7528\u4e0a&#xff0c;\u8fd9\u662f\u5224\u65ad\u5206\u914d\u91cf\u7684\u524d\u63d0\u3002\u4e0b\u8868\u662f Unity \u7684 Mono\/IL2CPP \u811a\u672c\u540e\u7aef\u4e0a\u7684\u5178\u578b\u964d\u7ea7\u884c\u4e3a&#xff08;\u4ee5\u4f60\u6240\u7528 Unity \u7248\u672c\u7684\u7f16\u8bd1\u5668\u4e3a\u51c6&#xff0c;\u4e0d\u540c\u7248\u672c Roslyn \u6709\u7ec6\u8282\u5dee\u5f02&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\u5199\u6cd5\u964d\u7ea7\u76ee\u6807\u5206\u914d\u6765\u6e90\u5178\u578b\u4f30\u7b97<\/tr>\n<tbody>\n<tr>\n<td>a &#043; b<\/td>\n<td>string.Concat(string, string)<\/td>\n<td>1 \u4e2a\u65b0\u5b57\u7b26\u4e32<\/td>\n<td>\u6bcf\u6b21 1 \u4e2a\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>a &#043; b &#043; c<\/td>\n<td>string.Concat(string, string, string)<\/td>\n<td>1 \u4e2a\u65b0\u5b57\u7b26\u4e32<\/td>\n<td>\u6bcf\u6b21 1 \u4e2a\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>a &#043; b &#043; c &#043; d&#xff08;4 \u9879\u53ca\u4ee5\u4e0a&#xff09;<\/td>\n<td>string.Concat(params string[])<\/td>\n<td>\u53c2\u6570\u6570\u7ec4 &#043; \u65b0\u5b57\u7b26\u4e32<\/td>\n<td>\u6bcf\u6b21 2 \u4e2a\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>&#034;x &#061; &#034; &#043; x&#xff08;x \u4e3a int&#xff09;<\/td>\n<td>\u5148\u00a0x.ToString()\u00a0\u518d\u00a0Concat<\/td>\n<td>\u88c5\u7bb1\u65e0\u5173&#xff0c;\u4f46\u591a\u4e00\u4e2a int.ToString \u4e32<\/td>\n<td>\u6bcf\u6b21 2 \u4e2a\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>$&#034;{hp}\/{max}&#034;<\/td>\n<td>\u65e7\u8fd0\u884c\u65f6\u591a\u4e3a\u00a0string.Format&#xff0c;\u7b80\u5355\u573a\u666f\u964d\u4e3a\u00a0Concat<\/td>\n<td>\u683c\u5f0f\u5316\u6570\u7ec4\u3001\u88c5\u7bb1\u3001\u7ed3\u679c\u4e32<\/td>\n<td>\u6bcf\u6b21 2~4 \u4e2a\u5bf9\u8c61&#xff08;\u793a\u4f8b\u91cf\u7ea7&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>string.Format(&#034;{0}\/{1}&#034;, hp, max)<\/td>\n<td>\u539f\u6837\u8c03\u7528<\/td>\n<td>object[]\u00a0\u6570\u7ec4 &#043; \u4e24\u4e2a\u88c5\u7bb1 &#043; \u7ed3\u679c\u4e32<\/td>\n<td>\u6bcf\u6b21 4 \u4e2a\u8d77&#xff08;\u793a\u4f8b\u91cf\u7ea7&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5faa\u73af\u5185\u00a0s &#043;&#061; item<\/td>\n<td>\u6bcf\u8f6e\u4e00\u6b21\u00a0Concat<\/td>\n<td>\u6bcf\u8f6e 1 \u4e2a\u65b0\u4e32&#xff0c;\u65e7\u4e32\u53d8\u5783\u573e<\/td>\n<td>n \u8f6e n \u4e2a\u5bf9\u8c61&#xff0c;\u5b57\u7b26\u590d\u5236 O(n\u00b2)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6709\u4e24\u884c\u503c\u5f97\u5c55\u5f00\u3002\u7b2c\u4e00\u662f\u00a0params string[]&#xff1a;\u4e00\u65e6\u62fc\u63a5\u9879\u8d85\u8fc7\u4e09\u4e2a&#xff0c;\u7f16\u8bd1\u5668\u5c31\u4f1a\u5206\u914d\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4\u6765\u586b\u00a0params\u00a0\u53c2\u6570&#xff0c;\u6570\u7ec4\u672c\u8eab\u4e5f\u662f\u6258\u7ba1\u5806\u5bf9\u8c61&#xff0c;\u8fd9\u662f\u5f88\u591a\u4eba\u6ca1\u610f\u8bc6\u5230\u7684&#034;\u591a\u51fa\u6765\u7684\u4e00\u4e2a\u5206\u914d&#034;\u3002\u7b2c\u4e8c\u662f\u63d2\u503c\u5b57\u7b26\u4e32&#xff1a;Unity \u7684\u811a\u672c\u540e\u7aef\u8d70\u7684 API \u9762\u5927\u7ea6\u662f .NET Standard 2.1 \u4e00\u7ea7&#xff0c;\u6ca1\u6709 .NET 6 \u5f15\u5165\u7684\u00a0DefaultInterpolatedStringHandler&#xff0c;\u6240\u4ee5\u00a0$&#034;&#034;\u00a0\u7684\u5b9e\u9645\u6210\u672c\u63a5\u8fd1\u00a0string.Format&#xff0c;\u53c2\u6570\u91cc\u6709\u503c\u7c7b\u578b\u65f6\u88c5\u7bb1\u51e0\u4e4e\u8dd1\u4e0d\u6389&#xff0c;\u7b2c\u4e94\u8282\u4f1a\u5c55\u5f00\u3002<\/p>\n<h4 id=\"32-\u574f\u5199\u6cd5\u4e0e\u597d\u5199\u6cd5\u5bf9\u7167\">3.2 \u574f\u5199\u6cd5\u4e0e\u597d\u5199\u6cd5\u5bf9\u7167<\/h4>\n<p>\u5148\u770b\u5faa\u73af\u62fc\u63a5\u8fd9\u4e2a\u6700\u7ecf\u5178\u7684\u53cd\u4f8b&#xff0c;\u4ee5\u53ca\u5b83\u5bf9\u5e94\u7684\u6539\u6cd5&#xff1a;<\/p>\n<p>\/\/ \u9519\u8bef&#xff1a;\u6bcf\u6b21\u62fc\u63a5\u4ea7\u751f\u65b0\u5b57\u7b26\u4e32<br \/>\nstring msg &#061; &#034;&#034;;<br \/>\nfor (int i &#061; 0; i &lt; 100; i&#043;&#043;) msg &#043;&#061; i &#043; &#034;,&#034;;<\/p>\n<p>\/\/ \u6b63\u786e&#xff1a;StringBuilder \u96f6\u591a\u4f59\u5206\u914d<br \/>\nvar sb &#061; new StringBuilder(512);<br \/>\nfor (int i &#061; 0; i &lt; 100; i&#043;&#043;) sb.Append(i).Append(&#039;,&#039;);<br \/>\nstring msg &#061; sb.ToString(); \/\/ \u53ea\u6709\u4e00\u6b21\u5206\u914d<\/p>\n<p>\u9010\u6bb5\u89e3\u8bfb\u8fd9\u6bb5\u574f\u4ee3\u7801\u3002msg &#043;&#061; i &#043; &#034;,&#034;\u00a0\u8fd9\u4e00\u884c\u91cc\u5176\u5b9e\u53e0\u4e86\u4e09\u5c42\u5206\u914d&#xff1a;i &#043; &#034;,&#034;\u00a0\u5148\u505a\u4e00\u6b21 int \u5230\u5b57\u7b26\u4e32\u7684\u8f6c\u6362\u52a0\u62fc\u63a5&#xff0c;\u4ea7\u751f\u4e00\u4e2a\u4e34\u65f6\u4e32&#xff1b;\u7136\u540e\u00a0msg &#043; \u4e34\u65f6\u4e32\u00a0\u518d\u8c03\u4e00\u6b21\u00a0string.Concat&#xff0c;\u4ea7\u751f\u4e00\u4e2a\u6bd4\u4e0a\u4e00\u8f6e\u66f4\u957f\u7684\u65b0\u4e32&#xff1b;\u4e0a\u4e00\u8f6e\u7684\u00a0msg\u00a0\u5931\u53bb\u5f15\u7528\u53d8\u6210\u5783\u573e\u3002100 \u8f6e\u4e0b\u6765\u4ea7\u751f\u7ea6 200 \u4e2a\u5b57\u7b26\u4e32\u5bf9\u8c61&#xff08;\u793a\u4f8b\u91cf\u7ea7&#xff09;&#xff0c;\u66f4\u8981\u547d\u7684\u662f\u5b57\u7b26\u590d\u5236\u603b\u91cf\u662f 1 \u52a0 2 \u52a0 3 \u4e00\u76f4\u52a0\u5230 100&#xff0c;\u4e5f\u5c31\u662f O(n\u00b2) \u91cf\u7ea7\u7684\u5b57\u7b26\u642c\u8fd0&#xff1a;\u5217\u8868\u8d8a\u957f\u6d6a\u8d39\u589e\u957f\u8d8a\u5feb&#xff0c;1000 \u9879\u7684\u5faa\u73af\u642c\u8fd0\u7684\u5b57\u7b26\u6570\u4f1a\u5230\u6700\u7ec8\u4e32\u7684\u51e0\u767e\u500d\u3002<\/p>\n<p>\u518d\u770b\u597d\u7684\u90a3\u6bb5\u3002StringBuilder\u00a0\u5185\u90e8\u6301\u6709\u4e00\u5757\u5b57\u7b26\u7f13\u51b2\u533a&#xff0c;Append\u00a0\u53ea\u662f\u628a\u5b57\u7b26\u5199\u8fdb\u7f13\u51b2\u533a\u5c3e\u90e8&#xff0c;\u7f13\u51b2\u533a\u88c5\u5f97\u4e0b\u5c31\u4e0d\u518d\u4ea7\u751f\u4efb\u4f55\u6258\u7ba1\u5206\u914d\u3002Append(i)\u00a0\u8d70\u7684\u662f\u4e0d\u88c5\u7bb1\u7684\u6cdb\u578b\u91cd\u8f7d&#xff08;Append(int)\u00a0\u76f4\u63a5\u628a\u6570\u5b57\u683c\u5f0f\u5316\u8fdb\u7f13\u51b2\u533a&#xff09;&#xff0c;\u8fde ToString \u7684\u4e34\u65f6\u4e32\u90fd\u7701\u4e86\u3002\u6574\u6bb5\u5faa\u73af\u6700\u7ec8\u53ea\u5728\u00a0sb.ToString()\u00a0\u65f6\u4ea7\u751f\u4e00\u4e2a\u7ed3\u679c\u5b57\u7b26\u4e32\u3002\u6784\u9020\u65f6\u4f20\u5165 512 \u662f\u9884\u4f30\u5bb9\u91cf&#xff0c;\u4f30\u7b97\u504f\u5c0f\u4e5f\u65e0\u59a8&#xff0c;\u53ea\u662f\u7f13\u51b2\u533a\u4f1a\u6309\u9700\u7ffb\u500d\u6269\u5bb9&#xff0c;\u591a\u4ea7\u751f\u4e00\u4e24\u6b21\u6570\u7ec4\u62f7\u8d1d\u3002<\/p>\n<h4 id=\"33-\u62fc\u63a5\u65b9\u5f0f\u600e\u4e48\u9009\">3.3 \u62fc\u63a5\u65b9\u5f0f\u600e\u4e48\u9009<\/h4>\n<p>\u5b9e\u8df5\u4e2d\u7684\u9009\u62e9\u53ef\u4ee5\u6536\u6210\u4e00\u5f20\u51b3\u7b56\u8868&#xff1a;<\/p>\n<table>\n<tr>\u573a\u666f\u63a8\u8350\u5199\u6cd5\u7406\u7531<\/tr>\n<tbody>\n<tr>\n<td>\u4e24\u4e09\u4e2a\u5b57\u7b26\u4e32\u62fc\u4e00\u6b21&#xff0c;\u4f4e\u9891\u8c03\u7528<\/td>\n<td>&#043;\u00a0\u6216\u00a0$&#034;&#034;<\/td>\n<td>\u53ef\u8bfb\u6027\u6700\u597d&#xff0c;\u5206\u914d\u91cf\u4e5f\u53ef\u63a5\u53d7<\/td>\n<\/tr>\n<tr>\n<td>\u5faa\u73af\u5185\u62fc\u63a5\u3001\u65e5\u5fd7\u805a\u5408\u3001\u534f\u8bae\u7ec4\u5305<\/td>\n<td>StringBuilder&#xff0c;\u9884\u4f30\u5bb9\u91cf<\/td>\n<td>\u5355\u7ed3\u679c\u5206\u914d&#xff0c;\u907f\u514d O(n\u00b2) \u590d\u5236<\/td>\n<\/tr>\n<tr>\n<td>\u6bcf\u5e27\u6267\u884c\u7684\u6587\u672c\u62fc\u63a5<\/td>\n<td>\u5148\u6d88\u706d\u62fc\u63a5\u9700\u6c42&#xff0c;\u975e\u7559\u4e0d\u53ef\u518d\u7528\u590d\u7528\u7684 StringBuilder<\/td>\n<td>\u89c1\u7b2c\u516d\u8282&#xff0c;\u6bcf\u5e27 ToString \u7ed3\u679c\u4ecd\u662f\u5206\u914d<\/td>\n<\/tr>\n<tr>\n<td>\u5927\u91cf\u540c\u7ed3\u6784\u6587\u672c&#xff08;\u5982 CSV \u4e00\u884c&#xff09;<\/td>\n<td>string.Join\u00a0\u6216\u00a0Span\/string.Create&#xff08;\u53c2\u89c1 08-07&#xff09;<\/td>\n<td>Join \u5185\u90e8\u4e00\u6b21\u8ba1\u7b97\u603b\u957f\u518d\u4e00\u6b21\u5206\u914d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>string.Join\u00a0\u5148\u904d\u5386\u7b97\u51fa\u603b\u957f\u5ea6\u518d\u4e00\u6b21\u5206\u914d\u5e76\u586b\u5145&#xff0c;\u6ca1\u6709\u4e2d\u95f4\u5783\u573e\u4e32&#xff0c;&#034;\u5f88\u591a\u77ed\u4e32\u62fc\u6210\u957f\u4e32&#034;\u65f6\u5206\u914d\u6b21\u6570\u663e\u8457\u5c11\u4e8e\u624b\u5199\u5faa\u73af\u52a0\u52a0\u3002<\/p>\n<h3 id=\"\u56db-substring-\u4e0e\u5207\u7247\u5c0f\u7a97\u53e3\u5927\u590d\u5236\">\u56db\u3001Substring \u4e0e\u5207\u7247&#xff1a;\u5c0f\u7a97\u53e3\u5927\u590d\u5236<\/h3>\n<h4 id=\"41-substring-\u7684\u5206\u914d\u8def\u5f84\">4.1 Substring \u7684\u5206\u914d\u8def\u5f84<\/h4>\n<p>Substring \u4f1a\u590d\u5236\u539f\u5b57\u7b26\u4e32\u7684\u4e00\u90e8\u5206\u521b\u5efa\u65b0\u5b57\u7b26\u4e32&#xff0c;\u5927\u5b57\u7b26\u4e32\u53d6\u5c0f\u90e8\u5206\u65f6\u6d6a\u8d39\u660e\u663e\u3002\u8fd9\u6761\u5728 Unity \u7684 Mono \u4e0e IL2CPP \u540e\u7aef\u4e0a\u6210\u7acb&#xff0c;\u5c55\u5f00\u770b\u5b83\u7684\u4ee3\u4ef7&#xff1a;<\/p>\n<p>\/\/ \u4ece\u4e00\u4efd 100KB \u7684\u914d\u7f6e\u6587\u672c\u91cc\u53cd\u590d\u622a\u53d6\u5c0f\u6bb5<br \/>\nstring big &#061; LoadConfigText();          \/\/ \u5047\u8bbe 100KB&#xff0c;\u7ea6 5 \u4e07\u4e2a\u5b57\u7b26<br \/>\nfor (int i &#061; 0; i &lt; parsedKeys.Count; i&#043;&#043;)<br \/>\n{<br \/>\n    string key &#061; big.Substring(start[i], length[i]);   \/\/ \u6bcf\u6b21\u90fd\u662f\u5168\u65b0\u5b57\u7b26\u4e32<br \/>\n    table[key] &#061; i;<br \/>\n}<\/p>\n<p>\u9010\u6bb5\u89e3\u8bfb\u3002big\u00a0\u53ea\u52a0\u8f7d\u4e00\u6b21&#xff0c;\u8fd9\u6ca1\u95ee\u9898&#xff1b;\u95ee\u9898\u5168\u5728\u5faa\u73af\u4f53\u91cc\u90a3\u4e00\u6b21\u00a0Substring\u3002\u5b83\u505a\u7684\u4e24\u4ef6\u4e8b\u662f&#xff1a;\u5728\u5806\u4e0a\u5206\u914d\u4e00\u4e2a\u5168\u65b0\u7684 string \u5bf9\u8c61&#xff0c;\u7136\u540e\u628a\u00a0big\u00a0\u91cc\u4ece\u00a0start[i]\u00a0\u5f00\u59cb\u3001\u957f\u5ea6\u00a0length[i]\u00a0\u7684\u90a3\u6bb5\u5b57\u7b26\u590d\u5236\u8fdb\u53bb\u3002\u539f\u4e32\u00a0big\u00a0\u4e00\u4e2a\u5b57\u8282\u90fd\u4e0d\u4f1a\u88ab\u7701\u7565&#xff0c;\u5b83\u59cb\u7ec8\u5b8c\u6574\u5730\u5360\u7740\u90a3 100KB\u3002\u4e8e\u662f\u540c\u4e00\u4efd\u6570\u636e\u5728\u5185\u5b58\u91cc\u5b58\u5728\u4e24\u4efd\u62f7\u8d1d&#xff1a;\u5b8c\u6574\u7684\u914d\u7f6e\u4e32&#xff0c;\u52a0\u4e0a\u82e5\u5e72\u4e2a\u4ece\u5b83\u8eab\u4e0a\u590d\u5236\u51fa\u6765\u7684\u5c0f\u4e32\u3002\u5faa\u73af 500 \u6b21\u5c31\u662f 500 \u4e2a\u65b0\u5b57\u7b26\u4e32\u5bf9\u8c61\u52a0 500 \u6b21\u5b57\u7b26\u590d\u5236&#xff0c;\u800c\u8fd9\u4e9b\u5c0f\u4e32\u591a\u6570\u7528\u5b8c\u952e\u503c\u5bf9\u6784\u9020\u5c31\u6b7b\u4e86&#xff0c;\u7eaf\u7cb9\u662f\u8fc7\u8def\u5783\u573e\u3002<\/p>\n<p>\u590d\u5236\u8fc7\u7a0b\u7528\u56fe\u770b\u66f4\u76f4\u89c2&#xff1a;<\/p>\n<p>\u539f\u4e32 big&#xff08;100KB&#xff0c;\u5e38\u9a7b&#xff09;&#xff1a;<br \/>\n[&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 5\u4e07\u5b57\u7b26 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;]<br \/>\n                                              \u25b2<br \/>\nSubstring(start&#061;1000, len&#061;8) \u4f1a\u505a\u7684\u4e8b&#xff1a;        \u2502 \u622a\u53d6\u7a97\u53e3<br \/>\n                                              \u25bc<br \/>\n\u65b0\u4e32 key&#xff08;\u6bcf\u6b21\u5faa\u73af\u90fd\u65b0\u5206\u914d&#xff09;&#xff1a;<br \/>\n[\u5bf9\u8c61\u5934][len&#061;8][&#039;k&#039;,&#039;e&#039;,&#039;y&#039;,&#039;N&#039;,&#039;a&#039;,&#039;m&#039;,&#039;e&#039;,&#039;!&#039;]     \u2190 \u72ec\u7acb\u526f\u672c&#xff0c;\u4e0e big \u65e0\u5171\u4eab<\/p>\n<p>\u987a\u5e26\u8bf4\u6e05\u695a\u4e00\u4e2a\u5e38\u89c1\u7591\u95ee&#xff1a;\u684c\u9762 .NET \u4e0a\u6709\u4eba\u8bf4 Substring \u4e0d\u590d\u5236&#xff0c;\u6709\u4e9b\u8fd0\u884c\u65f6\u7248\u672c\u4e5f\u786e\u5b9e\u5bf9\u5b83\u505a\u8fc7\u5185\u90e8\u4f18\u5316&#xff0c;\u4f46\u7ed3\u8bba\u4e0d\u80fd\u642c\u5230 Unity&#xff1a;Mono \u4e0e IL2CPP \u540e\u7aef\u6309&#034;\u5206\u914d\u52a0\u590d\u5236&#034;\u5b9e\u73b0&#xff0c;\u5b98\u65b9\u6587\u6863\u4e5f\u6ca1\u6709\u96f6\u62f7\u8d1d\u627f\u8bfa\u3002\u5199 Unity \u4ee3\u7801\u6309\u6700\u574f\u60c5\u51b5\u505a\u6027\u80fd\u9884\u7b97&#xff0c;\u624d\u4e0d\u4f1a\u5728\u771f\u673a\u4e0a\u88ab\u6253\u8138\u3002<\/p>\n<h4 id=\"42-\u6539\u6cd5\u7d22\u5f15\u5316-span-\u7ed3\u679c\u7f13\u5b58\">4.2 \u6539\u6cd5&#xff1a;\u7d22\u5f15\u5316\u3001Span\u3001\u7ed3\u679c\u7f13\u5b58<\/h4>\n<p>\u6539\u6cd5\u6309\u4fb5\u5165\u6027\u4ece\u4f4e\u5230\u9ad8\u6392\u4e09\u79cd\u3002\u7b2c\u4e00\u79cd\u662f\u7d22\u5f15\u5316&#xff1a;\u4e0d\u8981\u628a\u5c0f\u7a97\u53e3\u7acb\u523b\u53d8\u6210\u5b57\u7b26\u4e32&#xff0c;\u628a&#034;\u8d77\u70b9\u52a0\u957f\u5ea6&#034;\u8fd9\u5bf9\u7d22\u5f15\u4f20\u4e0b\u53bb&#xff0c;\u771f\u6b63\u9700\u8981\u5b57\u7b26\u4e32\u7684\u4f4d\u7f6e\u53ea\u8f6c\u6362\u4e00\u6b21\u3002\u5bf9 4.1 \u7684\u4f8b\u5b50&#xff0c;\u82e5\u8fd9\u4e9b\u5c0f\u7a97\u53e3\u53ea\u7528\u4e8e\u4e34\u65f6\u67e5\u627e&#xff0c;\u5b8c\u5168\u53ef\u4ee5\u6539\u6210\u5bf9\u539f\u4e32\u7684\u8303\u56f4\u6bd4\u8f83&#xff0c;\u53ea\u5728\u6700\u7ec8\u8981\u957f\u671f\u6301\u6709\u7684\u952e\u4e0a\u8f6c\u4e00\u6b21\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u7b2c\u4e8c\u79cd\u662f\u7528\u00a0ReadOnlySpan&lt;char&gt;\u00a0\u8868\u793a\u5207\u7247&#xff0c;Span \u7684\u5207\u7247\u53ea\u662f\u4e24\u4e2a\u5b57\u6bb5\u7684\u504f\u79fb&#xff0c;\u4e0d\u5206\u914d\u4e0d\u590d\u5236\u3002Unity \u7248\u672c\u8f83\u65b0\u7684\u9879\u76ee\u53ef\u4ee5\u5728\u70ed\u8def\u5f84\u4e0a\u7528\u5b83&#xff0c;\u7ec6\u8282\u4e0e\u66f4\u591a\u96f6\u5206\u914d\u6280\u5de7\u53c2\u89c1\u672c\u7bc7 08-07\u300aSpan \u4e0e\u96f6\u5206\u914d\u7f16\u7a0b\u300b\u3002<\/p>\n<p>\u7b2c\u4e09\u79cd\u662f\u7ed3\u679c\u7f13\u5b58&#xff1a;\u540c\u4e00\u4e2a\u5207\u7247\u7ed3\u679c\u5728\u4e00\u4e2a\u903b\u8f91\u5e27\u6216\u4e00\u6b21\u89e3\u6790\u91cc\u88ab\u53cd\u590d\u4f7f\u7528\u65f6&#xff0c;\u53ea\u622a\u53d6\u4e00\u6b21\u5b58\u8d77\u6765\u3002\u8fd9\u6761\u5bf9&#034;\u6bcf\u5e27 Substring \u540c\u4e00\u6bb5&#034;\u7684\u4ee3\u7801\u5c24\u5176\u6709\u6548&#xff0c;\u628a\u6bcf\u5e27 N \u6b21\u5206\u914d\u53d8\u6210\u6bcf\u6b21\u914d\u7f6e\u53d8\u66f4 N \u6b21\u5206\u914d\u3002<\/p>\n<h3 id=\"\u4e94-tostring-\u4e0e\u88c5\u7bb1\u7684\u53e0\u52a0\u6548\u5e94\">\u4e94\u3001ToString \u4e0e\u88c5\u7bb1\u7684\u53e0\u52a0\u6548\u5e94<\/h3>\n<h4 id=\"51-\u503c\u7c7b\u578b-tostring-\u672c\u8eab\u5c31\u5206\u914d\">5.1 \u503c\u7c7b\u578b ToString \u672c\u8eab\u5c31\u5206\u914d<\/h4>\n<p>\u503c\u7c7b\u578b\u7684 ToString \u8d70\u7684\u901a\u5e38\u662f Number.ToString \u90a3\u4e00\u5957\u5b9e\u73b0&#xff0c;\u4ea7\u51fa\u5fc5\u7136\u662f\u4e00\u6b21\u5b57\u7b26\u4e32\u5206\u914d&#xff0c;\u6027\u80fd\u70ed\u8def\u5f84\u4e2d\u5e94\u7f13\u5b58\u6216\u907f\u514d\u8c03\u7528\u3002\u8865\u4e0a\u91cf\u7ea7\u89c6\u89d2&#xff1a;\u4e00\u4e2a\u00a0int\u00a0\u7684 ToString \u5728\u5806\u4e0a\u4ea7\u751f\u4e00\u4e2a 1 \u5230 10 \u5b57\u7b26\u4e0d\u7b49\u7684\u65b0\u5b57\u7b26\u4e32&#xff08;\u8d1f\u6570\u66f4\u957f&#xff09;&#xff0c;\u5bf9\u8c61\u5934\u52a0\u5b57\u7b26\u6570\u636e\u7ea6 24 \u5230 32 \u5b57\u8282&#xff08;\u5178\u578b\u4f30\u7b97&#xff0c;\u968f\u8fd0\u884c\u65f6\u5bf9\u9f50\u65b9\u5f0f\u6d6e\u52a8&#xff09;\u3002\u5355\u770b\u5f88\u5c0f&#xff0c;\u4f46 ToString \u5f80\u5f80\u4e0d\u662f\u5b64\u7acb\u8c03\u7528&#xff0c;\u5b83\u7ecf\u5e38\u548c\u62fc\u63a5\u3001\u683c\u5f0f\u5316\u53e0\u5728\u4e00\u8d77\u6210\u4e32\u51fa\u73b0\u3002<\/p>\n<h4 id=\"52-\u88c5\u7bb1\u662f\u600e\u4e48\u53e0\u8fdb\u6765\u7684\">5.2 \u88c5\u7bb1\u662f\u600e\u4e48\u53e0\u8fdb\u6765\u7684<\/h4>\n<p>\u771f\u6b63\u628a ToString \u7684\u6210\u672c\u63a8\u4e0a\u53bb\u7684\u662f\u5b83\u4e0e\u88c5\u7bb1\u3001\u683c\u5f0f\u5316 API \u7684\u7ec4\u5408\u3002\u770b\u4e00\u7ec4\u5bf9\u7167&#xff1a;<\/p>\n<p>\/\/ \u574f&#xff1a;\u4e09\u5c42\u53e0\u52a0&#xff0c;\u5b57\u7b26\u4e32 &#043; \u88c5\u7bb1 &#043; \u6570\u7ec4<br \/>\nint hp &#061; 1234;<br \/>\nstring s1 &#061; hp.ToString();                          \/\/ \u5206\u914d 1 \u4e2a\u5b57\u7b26\u4e32<br \/>\nstring s2 &#061; string.Format(&#034;{0}\/{1}&#034;, hp, max);      \/\/ object[] \u6570\u7ec4 &#043; 2 \u4e2a\u88c5\u7bb1 &#043; 1 \u4e2a\u7ed3\u679c\u4e32<br \/>\nstring s3 &#061; $&#034;{hp}\/{max}&#034;;                          \/\/ Unity \u8fd0\u884c\u65f6\u4e0a\u63a5\u8fd1 Format \u7684\u8def\u5f84<br \/>\nstring s4 &#061; string.Concat(hp, &#034;\/&#034;, max);            \/\/ Concat(object,&#8230;) \u91cd\u8f7d&#xff1a;2 \u6b21\u9690\u5f0f ToString<\/p>\n<p>\/\/ \u597d&#xff1a;\u4e0d\u88c5\u7bb1\u3001\u6309\u9700\u5206\u914d<br \/>\nvar sb &#061; new StringBuilder(24);<br \/>\nsb.Append(hp).Append(&#039;\/&#039;).Append(max);              \/\/ Append(int) \u4e0d\u88c5\u7bb1\u4e0d\u5efa\u4e34\u65f6\u4e32<br \/>\nstring s5 &#061; sb.ToString();                          \/\/ \u53ea\u5728\u771f\u9700\u8981\u5b57\u7b26\u4e32\u65f6\u5206\u914d\u4e00\u6b21<\/p>\n<p>\u9010\u6bb5\u89e3\u8bfb\u3002\u7b2c\u4e00\u884c\u00a0hp.ToString()\u00a0\u662f\u6700\u5355\u7eaf\u7684\u5206\u914d&#xff1a;\u4e00\u4e2a\u77ed\u547d\u5b57\u7b26\u4e32&#xff0c;\u6ca1\u6709\u522b\u7684\u5f00\u9500\u3002\u7b2c\u4e8c\u884c\u00a0string.Format\u00a0\u7684\u53c2\u6570\u8868\u8981\u6c42\u00a0object&#xff0c;\u4e24\u4e2a\u00a0int\u00a0\u5404\u88ab\u88c5\u7bb1\u4e00\u6b21&#xff0c;\u88c5\u7bb1\u610f\u5473\u7740\u5728\u5806\u4e0a\u5206\u914d\u76d2\u5b50\u5bf9\u8c61\u518d\u628a\u503c\u62f7\u8fdb\u53bb&#xff08;\u88c5\u7bb1\u673a\u5236\u89c1 08-04 \u4e13\u7ae0&#xff0c;\u672c\u6587\u53ea\u770b\u5b83\u5728\u5b57\u7b26\u4e32\u8def\u5f84\u4e0a\u7684\u53e0\u52a0&#xff09;&#xff1b;\u540c\u65f6\u53ef\u53d8\u53c2\u6570\u8fd8\u4f1a\u5206\u914d\u4e00\u4e2a\u00a0object[]\u00a0\u6570\u7ec4\u88c5\u4e0b\u8fd9\u4e24\u4e2a\u76d2\u5b50&#xff0c;\u6700\u540e\u624d\u662f\u683c\u5f0f\u5316\u5f15\u64ce\u626b\u63cf\u683c\u5f0f\u4e32\u3001\u5199\u8fdb\u7ed3\u679c\u5b57\u7b26\u4e32\u3002\u4e00\u6b21\u8c03\u7528\u56db\u4e2a\u6258\u7ba1\u5bf9\u8c61&#xff0c;\u5176\u4e2d\u4e09\u4e2a\u5728\u7ed3\u679c\u5b57\u7b26\u4e32\u4e4b\u5916\u7eaf\u5c5e\u8fc7\u8def\u3002<\/p>\n<p>\u7b2c\u4e09\u884c\u63d2\u503c\u5b57\u7b26\u4e32\u5728 Unity \u7684\u8fd0\u884c\u65f6\u9762\u4e0a\u8d70\u7684\u8fd8\u662f\u683c\u5f0f\u5316\u8def\u5f84&#xff0c;\u88c5\u7bb1\u4e0e\u6570\u7ec4\u4e00\u4e2a\u4e0d\u5c11&#xff0c;\u5199\u6cd5\u53d8\u4f18\u96c5\u4e86&#xff0c;GC \u6210\u672c\u6ca1\u6709\u53d8\u4f18\u96c5\u3002\u7b2c\u56db\u884c\u5bb9\u6613\u88ab\u5f53\u6210&#034;Concat \u66f4\u5feb\u6240\u4ee5\u66f4\u7701&#034;&#xff0c;\u5b9e\u9645\u4e0a\u00a0string.Concat(params object[])\u00a0\u8fd9\u4e00\u65cf\u91cd\u8f7d\u5185\u90e8\u4ecd\u7136\u9010\u4e2a\u8c03\u7528\u53c2\u6570\u7684 ToString&#xff0c;\u4e24\u4e2a\u88c5\u7bb1\u7167\u6837\u53d1\u751f&#xff0c;\u53ea\u662f\u6570\u7ec4\u53ef\u80fd\u88ab\u4f18\u5316\u6389\u3002\u53f3\u8fb9\u7684\u597d\u5199\u6cd5\u4e4b\u6240\u4ee5\u5e72\u51c0&#xff0c;\u9760\u7684\u662f\u4e24\u4ef6\u4e8b&#xff1a;Append(int)\u00a0\u8fd9\u7c7b\u6cdb\u578b\u91cd\u8f7d\u76f4\u63a5\u628a\u6570\u5b57\u5199\u8fdb\u7f13\u51b2\u533a&#xff0c;\u7ed5\u5f00\u4e86 ToString \u4e0e\u88c5\u7bb1&#xff1b;\u7ed3\u679c\u4e32\u53ea\u5728\u771f\u6b63\u9700\u8981 string \u7684\u8fb9\u754c\u4e0a\u4ea7\u751f\u4e00\u6b21\u3002<\/p>\n<h4 id=\"53-\u70ed\u8def\u5f84\u4e0a\u7684\u7b56\u7565\">5.3 \u70ed\u8def\u5f84\u4e0a\u7684\u7b56\u7565<\/h4>\n<p>\u70ed\u8def\u5f84\u4e0a\u5bf9 ToString \u7684\u6b63\u786e\u6001\u5ea6\u662f&#034;\u80fd\u4e0d\u8f6c\u5c31\u4e0d\u8f6c&#xff0c;\u975e\u8f6c\u4e0d\u53ef\u5c31\u6512\u4e00\u6b21&#034;\u3002\u8ba1\u5206\u677f\u6bcf\u5e27\u66f4\u65b0\u65f6&#xff0c;\u5206\u6570\u6ca1\u53d8\u5c31\u4e0d\u8c03\u7528 ToString&#xff1b;\u53d8\u4e86\u4e5f\u53ea\u662f\u628a\u6570\u5b57 append \u8fdb\u590d\u7528\u7684 StringBuilder\u3002\u65e5\u5fd7\u7cfb\u7edf\u5982\u679c\u6bcf\u5e27\u90fd\u5728\u62fc\u53c2\u6570&#xff0c;\u5148\u628a&#034;\u662f\u5426\u5f00\u542f\u8be5\u7ea7\u522b\u65e5\u5fd7&#034;\u7684\u5224\u65ad\u653e\u5728\u62fc\u63a5\u4e4b\u524d&#xff0c;\u8ba9\u62fc\u63a5\u4ee3\u7801\u6839\u672c\u522b\u6267\u884c\u3002\u8fd8\u6709\u4e00\u7c7b\u9690\u853d\u70b9\u662f\u67e5\u627e\u7528\u7684 key&#xff1a;dict[key]\u00a0\u7684 key \u5982\u679c\u662f\u521a\u62fc\u51fa\u6765\u7684\u4e34\u65f6\u4e32&#xff0c;\u67e5\u627e\u672c\u8eab\u4e0d\u5206\u914d&#xff0c;\u4f46\u62fc key \u7684\u8fc7\u7a0b\u5df2\u7ecf\u4ed8\u8fc7\u4e00\u6b21\u8d26&#xff0c;\u628a\u70ed key \u7f13\u5b58\u6210\u5b57\u6bb5\u80fd\u76f4\u63a5\u780d\u6389\u8fd9\u6761\u94fe\u3002<\/p>\n<h3 id=\"\u516d-stringbuilder\u7f13\u51b2\u533a\u673a\u5236-\u9608\u503c\u4e0e\u8bef\u7528\">\u516d\u3001StringBuilder&#xff1a;\u7f13\u51b2\u533a\u673a\u5236\u3001\u9608\u503c\u4e0e\u8bef\u7528<\/h3>\n<h4 id=\"61-\u5185\u90e8\u673a\u5236\u56de\u987e\">6.1 \u5185\u90e8\u673a\u5236\u56de\u987e<\/h4>\n<p>StringBuilder \u5185\u90e8\u7ef4\u62a4\u5b57\u7b26\u7f13\u51b2\u533a&#xff0c;\u7f13\u51b2\u533a\u8db3\u591f\u65f6\u4e0d\u518d\u4ea7\u751f\u5206\u914d&#xff0c;\u5faa\u73af\u4e0e\u591a\u6b21\u62fc\u63a5\u573a\u666f\u90fd\u63a8\u8350\u5b83\u3002\u628a\u8fd9\u51e0\u53e5\u8bdd\u62c6\u5f00\u8bb2\u900f\u3002\u6838\u5fc3\u5b57\u6bb5\u662f\u4e00\u4e2a\u5b57\u7b26\u6570\u7ec4\u52a0\u4e00\u4e2a\u903b\u8f91\u957f\u5ea6&#xff0c;\u6bcf\u6b21 Append \u628a\u5b57\u7b26\u5199\u8fdb\u6570\u7ec4\u7684\u7a7a\u95f2\u5c3e\u90e8&#xff0c;\u53ea\u79fb\u52a8\u903b\u8f91\u957f\u5ea6&#xff0c;\u4e0d\u65b0\u5efa\u5b57\u7b26\u4e32\u3002\u6570\u7ec4\u88c5\u4e0d\u4e0b\u65f6\u6309\u7b56\u7565\u6269\u5bb9&#xff0c;\u5e38\u89c1\u7b56\u7565\u662f\u7ffb\u500d\u6216\u6309\u9700\u589e\u957f\u52a0\u4e00\u4e2a\u4f59\u91cf&#xff0c;\u6269\u5bb9\u4f1a\u5206\u914d\u65b0\u6570\u7ec4\u3001\u590d\u5236\u65e7\u5185\u5bb9\u3001\u91ca\u653e\u65e7\u6570\u7ec4&#xff0c;\u8fd9\u4e00\u4e0b\u662f\u771f\u5b9e\u7684\u5206\u914d&#xff0c;\u6240\u4ee5\u5bf9\u6700\u7ec8\u957f\u5ea6\u6709\u9884\u4f30\u65f6\u5b81\u53ef\u6784\u9020\u65f6\u4f20\u5165\u5bb9\u91cf&#xff0c;\u628a\u6269\u5bb9\u6b21\u6570\u538b\u5230\u96f6\u3002<\/p>\n<p>\u53e6\u4e00\u4e2a\u5173\u952e\u70b9\u662f\u00a0ToString()&#xff1a;\u5b83\u6309\u5f53\u524d\u903b\u8f91\u957f\u5ea6\u590d\u5236\u51fa\u4e00\u4e2a\u5168\u65b0\u7684 string\u3002\u4e5f\u5c31\u662f\u8bf4 StringBuilder \u53ea\u628a&#034;\u4e2d\u95f4\u8fc7\u7a0b&#034;\u7684\u5206\u914d\u6d88\u6389\u4e86&#xff0c;&#034;\u4ea7\u51fa\u6700\u7ec8\u5b57\u7b26\u4e32&#034;\u8fd9\u4e00\u6b21\u5206\u914d\u4ecd\u7136\u5728\u3002\u4e00\u6bb5\u4ee3\u7801\u82e5\u6bcf\u5e27\u8c03\u7528\u00a0sb.ToString()\u00a0\u5e76\u628a\u7ed3\u679c\u5b58\u8d77\u6765\u7528&#xff0c;\u90a3\u4e48\u65e0\u8bba StringBuilder \u590d\u7528\u5f97\u591a\u597d&#xff0c;\u6bcf\u5e27\u7167\u6837\u4ea7\u751f\u4e00\u4e2a\u7ed3\u679c\u5b57\u7b26\u4e32\u3002\u590d\u7528 StringBuilder \u89e3\u51b3\u7684\u662f\u8fc7\u7a0b\u5783\u573e&#xff0c;\u89e3\u51b3\u4e0d\u4e86\u7ed3\u679c\u5783\u573e\u3002<\/p>\n<h4 id=\"62-\u590d\u7528\u7684\u6b63\u786e\u59ff\u52bf\">6.2 \u590d\u7528\u7684\u6b63\u786e\u59ff\u52bf<\/h4>\n<p>\/\/ \u6bcf\u5e27\u590d\u7528\u7684 StringBuilder&#xff1a;\u7c7b\u5b57\u6bb5\u6301\u6709&#xff0c;Clear \u53ea\u6e05\u957f\u5ea6&#xff0c;\u4fdd\u7559\u5bb9\u91cf<br \/>\npublic class DamagePopup<br \/>\n{<br \/>\n    readonly System.Text.StringBuilder _sb &#061; new System.Text.StringBuilder(64);<\/p>\n<p>    public string Build(int amount, string suffix)<br \/>\n    {<br \/>\n        _sb.Clear();                 \/\/ \u957f\u5ea6\u5f52\u96f6&#xff0c;\u7f13\u51b2\u533a\u4fdd\u7559&#xff0c;\u65e0\u5206\u914d<br \/>\n        _sb.Append(&#039;-&#039;).Append(amount);   \/\/ Append(int)&#xff1a;\u683c\u5f0f\u5316\u8fdb\u7f13\u51b2\u533a&#xff0c;\u65e0\u4e2d\u95f4\u4e32<br \/>\n        if (!string.IsNullOrEmpty(suffix))<br \/>\n            _sb.Append(suffix);<br \/>\n        return _sb.ToString();       \/\/ \u672c\u6b21\u5faa\u73af\u552f\u4e00\u7684\u5b57\u7b26\u4e32\u5206\u914d<br \/>\n    }<br \/>\n}<\/p>\n<p>\u9010\u6bb5\u89e3\u8bfb\u3002_sb\u00a0\u653e\u5728\u7c7b\u5b57\u6bb5\u800c\u4e0d\u662f\u65b9\u6cd5\u5185&#xff0c;\u662f\u590d\u7528\u7684\u524d\u63d0&#xff1a;\u65b9\u6cd5\u5185\u00a0new StringBuilder()\u00a0\u6bcf\u6b21\u8c03\u7528\u90fd\u8981\u65b0\u5efa\u5bf9\u8c61&#xff0c;\u590d\u7528\u5c31\u65e0\u4ece\u8c08\u8d77\u3002Clear()\u00a0\u628a\u903b\u8f91\u957f\u5ea6\u5f52\u96f6\u4f46\u4e0d\u52a8\u5bb9\u91cf&#xff0c;\u8fd9\u662f\u5b83\u6bd4&#034;\u8d4b\u503c\u6210 new&#034;\u4f18\u8d8a\u7684\u5730\u65b9&#xff1b;\u53cd\u590d\u00a0new\u00a0\u7b49\u4e8e\u6bcf\u6b21\u91cd\u65b0\u8981\u4e00\u5757\u7f13\u51b2\u533a&#xff0c;\u65e7\u7684\u76f4\u63a5\u53d8\u5783\u573e\u3002Append(&#039;-&#039;)\u00a0\u4e0e\u00a0Append(amount)\u00a0\u8d70\u5b57\u7b26\u4e0e\u6574\u6570\u91cd\u8f7d&#xff0c;\u683c\u5f0f\u5316\u76f4\u63a5\u843d\u5728\u7f13\u51b2\u533a\u91cc\u3002\u672b\u5c3e\u7684\u00a0ToString()\u00a0\u662f\u552f\u4e00\u5206\u914d&#xff1a;\u7ed3\u679c\u5b58\u8fdb TMP \u7684 text \u5c5e\u6027\u65f6\u5b83\u4f1a\u6d3b\u5230\u4e0b\u6b21\u66f4\u65b0&#xff0c;\u5c5e\u4e8e\u7ed3\u679c\u5206\u914d&#xff1b;\u53ea\u7528\u4e8e\u65e5\u5fd7\u5224\u65ad\u5c31\u8be5\u5148\u5224\u65ad\u518d\u51b3\u5b9a\u8981\u4e0d\u8981 ToString\u3002<\/p>\n<h4 id=\"63-\u8bef\u7528\u6e05\u5355\">6.3 \u8bef\u7528\u6e05\u5355<\/h4>\n<p>\u628a\u5b9e\u8df5\u4e2d\u9ad8\u9891\u51fa\u73b0\u7684\u8bef\u7528\u5217\u6210\u8868&#xff0c;\u6bcf\u4e00\u6761\u90fd\u5bf9\u5e94\u524d\u9762\u8bb2\u8fc7\u7684\u673a\u5236&#xff1a;<\/p>\n<table>\n<tr>\u8bef\u7528\u4e3a\u4ec0\u4e48\u6709\u5bb3\u6b63\u786e\u505a\u6cd5<\/tr>\n<tbody>\n<tr>\n<td>\u5faa\u73af\u5185\u00a0new StringBuilder()<\/td>\n<td>\u590d\u7528\u65e0\u4ece\u8c08\u8d77&#xff0c;\u6bcf\u8f6e\u65b0\u5efa\u5bf9\u8c61<\/td>\n<td>\u7c7b\u5b57\u6bb5\u6301\u6709&#xff0c;Clear()\u00a0\u590d\u7528<\/td>\n<\/tr>\n<tr>\n<td>\u6bcf\u5e27\u00a0sb.ToString()\u00a0\u4e14\u7ed3\u679c\u4ec5\u7528\u4e00\u6b21<\/td>\n<td>\u8fc7\u7a0b\u96f6\u5206\u914d&#xff0c;\u7ed3\u679c\u4ecd\u6bcf\u5e27\u4e00\u4e2a\u4e32<\/td>\n<td>\u5148\u5224\u65ad\u662f\u5426\u771f\u9700\u8981\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<tr>\n<td>AppendFormat\u00a0\u9010\u6bb5\u62fc<\/td>\n<td>\u5185\u90e8\u8d70\u683c\u5f0f\u5316&#xff0c;\u6570\u7ec4\u4e0e\u88c5\u7bb1\u91cd\u65b0\u51fa\u73b0<\/td>\n<td>Append\u00a0\u7cfb\u5217\u91cd\u8f7d\u9010\u6bb5\u5199\u5165<\/td>\n<\/tr>\n<tr>\n<td>\u5bb9\u91cf\u4ece\u9ed8\u8ba4 16 \u4e00\u8def\u7ffb\u500d<\/td>\n<td>\u591a\u6b21\u6269\u5bb9\u52a0\u591a\u6b21\u590d\u5236<\/td>\n<td>\u6784\u9020\u65f6\u6309\u9884\u4f30\u4f20\u5bb9\u91cf<\/td>\n<\/tr>\n<tr>\n<td>\u7528 StringBuilder \u66ff\u4ee3\u5355\u6b21\u62fc\u63a5<\/td>\n<td>\u53cd\u800c\u591a\u8981\u4e00\u4e2a\u7f13\u51b2\u533a\u5bf9\u8c61<\/td>\n<td>\u5355\u6b21\u00a0&#043;\u00a0\u6216\u00a0$&#034;&#034;\u00a0\u66f4\u5212\u7b97<\/td>\n<\/tr>\n<tr>\n<td>\u628a StringBuilder \u5f53\u53c2\u6570\u5230\u5904\u4f20\u5e76\u5e76\u53d1\u4fee\u6539<\/td>\n<td>\u5355\u5b9e\u4f8b\u975e\u7ebf\u7a0b\u5b89\u5168&#xff0c;\u5171\u4eab\u5373\u4e8b\u6545<\/td>\n<td>\u6bcf\u4e2a\u4f7f\u7528\u8005\u5404\u81ea\u6301\u6709\u6216\u52a0\u9501<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8868\u91cc&#034;\u5355\u6b21\u62fc\u63a5\u4e0d\u503c\u5f97\u4e0a StringBuilder&#034;\u8fd9\u6761\u5e38\u88ab\u5ffd\u7565&#xff1a;StringBuilder \u5bf9\u8c61\u672c\u8eab\u4e5f\u6709\u5bf9\u8c61\u5934\u548c\u7f13\u51b2\u533a\u6570\u7ec4&#xff0c;\u4e00\u6b21\u6027\u62fc\u4e24\u4e09\u6bb5\u5c31\u4e22\u7684\u573a\u666f&#xff0c;a &#043; b\u00a0\u53ea\u4ea7\u751f\u4e00\u4e2a\u7ed3\u679c\u4e32&#xff0c;\u53cd\u800c\u6bd4&#034;new \u518d ToString&#034;\u5c11\u4e00\u4e2a\u4e2d\u95f4\u5bf9\u8c61\u3002\u5de5\u5177\u8981\u7528\u5728\u5b83\u5212\u7b97\u7684\u5730\u65b9\u3002<\/p>\n<h3 id=\"\u4e03-\u5b57\u7b26\u4e32\u6c60\u5316intern-\u5e94\u7528\u7ea7\u6c60\u4e0e\u547d\u540d\u6570\u636e\">\u4e03\u3001\u5b57\u7b26\u4e32\u6c60\u5316&#xff1a;Intern\u3001\u5e94\u7528\u7ea7\u6c60\u4e0e\u547d\u540d\u6570\u636e<\/h3>\n<h4 id=\"71-stringintern-\u7684\u8fb9\u754c\">7.1\u00a0string.Intern\u00a0\u7684\u8fb9\u754c<\/h4>\n<p>CLR \u5185\u7f6e\u4e86\u4e00\u4e2a\u9a7b\u7559\u6c60&#xff0c;string.Intern(s)\u00a0\u8fd4\u56de\u6c60\u4e2d\u5df2\u6709\u7684\u540c\u5185\u5bb9\u5b57\u7b26\u4e32&#xff0c;\u6ca1\u6709\u5c31\u767b\u8bb0\u8fdb\u53bb\u3002\u5b83\u5bf9&#034;\u6210\u5343\u4e0a\u4e07\u4e2a\u76f8\u540c\u77ed\u4e32&#034;\u7684\u573a\u666f\u5f88\u6709\u6548&#xff0c;\u6bd4\u5982\u4ece\u5927\u91cf\u6570\u636e\u884c\u91cc\u53cd\u590d\u8bfb\u53d6\u540c\u4e00\u7ec4\u679a\u4e3e\u5b57\u7b26\u4e32\u3002\u4f46\u8fb9\u754c\u5fc5\u987b\u5148\u8bb2\u6e05\u695a&#xff1a;\u9a7b\u7559\u6c60\u53ea\u8fdb\u4e0d\u51fa&#xff0c;\u5b57\u7b26\u4e32\u4e00\u65e6\u767b\u8bb0\u5c31\u957f\u671f\u9a7b\u7559&#xff0c;\u628a\u672c\u8be5\u88ab\u56de\u6536\u7684\u5b57\u7b26\u4e32\u53d8\u6210\u5e38\u9a7b\u5185\u5b58&#xff0c;\u53cd\u800c\u62ac\u9ad8\u5806\u6c34\u4f4d&#xff1b;\u5bf9\u8d85\u957f\u5b57\u7b26\u4e32\u505a Intern \u7684\u67e5\u627e\u6210\u672c\u4e5f\u4e0d\u4f4e&#xff1b;\u5728 IL2CPP \u540e\u7aef\u4e0a\u9a7b\u7559\u884c\u4e3a\u53d7\u5b9e\u73b0\u5dee\u5f02\u5f71\u54cd&#xff0c;\u4e0d\u80fd\u5047\u8bbe\u4e0e\u684c\u9762 .NET \u5b8c\u5168\u4e00\u81f4\u3002\u7ed3\u8bba\u662f Intern \u53ea\u9002\u5408&#034;\u6709\u9650\u96c6\u5408\u3001\u9ad8\u9891\u91cd\u590d\u3001\u751f\u547d\u5468\u671f\u672c\u5c31\u63a5\u8fd1\u9759\u6001&#034;\u7684\u5b57\u7b26\u4e32&#xff0c;\u4f8b\u5982\u534f\u8bae\u5b57\u6bb5\u540d\u3001\u914d\u7f6e\u952e\u540d\u3001\u6280\u80fd\u679a\u4e3e\u540d\u3002<\/p>\n<h4 id=\"72-\u5e94\u7528\u7ea7\u6c60\">7.2 \u5e94\u7528\u7ea7\u6c60<\/h4>\n<p>\u591a\u6570\u9879\u76ee\u66f4\u9002\u5408\u81ea\u5df1\u63a7\u5236\u7684\u5e94\u7528\u7ea7\u6c60\u3002\u5148\u770b\u4e00\u4e2a\u6700\u5c0f\u5b9e\u73b0&#xff0c;\u540e\u9762\u9010\u6bb5\u8bf4\u6e05\u695a\u5b83\u7684\u9002\u7528\u8fb9\u754c&#xff1a;<\/p>\n<p>\/\/ \u7b80\u5355\u7684\u5b57\u7b26\u4e32\u6c60\u5316\u5b9e\u73b0<br \/>\npublic static class StringPool {<br \/>\n    private static Dictionary&lt;string, string&gt; pool &#061; new();<br \/>\n    public static string Intern(string s) {<br \/>\n        if (pool.TryGetValue(s, out var cached)) return cached;<br \/>\n        pool[s] &#061; s;<br \/>\n        return s;<br \/>\n    }<br \/>\n}<br \/>\n\/\/ \u9002\u7528\u573a\u666f: \u5927\u91cf\u91cd\u590d\u5b57\u7b26\u4e32(\u5982\u7269\u54c1\u540d\u79f0\u3001\u7279\u6548\u540d\u79f0)<br \/>\n\/\/ string.Intern \u4f7f\u7528 CLR \u5185\u7f6e\u6c60, \u4e0a\u9762\u7684\u5b9e\u73b0\u4f7f\u7528\u5e94\u7528\u7ea7\u6c60, \u53ef\u6309\u9700\u6e05\u7406<\/p>\n<p>\u9010\u6bb5\u89e3\u8bfb\u3002\u8fd9\u4e2a\u6c60\u7684\u672c\u8d28\u662f\u4e00\u4e2a\u4ee5\u5b57\u7b26\u4e32\u5185\u5bb9\u4e3a\u952e\u7684\u5b57\u5178&#xff1a;\u65b0\u4e32\u8fdb\u6765\u5148\u67e5\u6709\u6ca1\u6709\u540c\u5185\u5bb9\u7684\u9a7b\u7559\u7248\u672c&#xff0c;\u6709\u5c31\u590d\u7528\u65e7\u7684&#xff0c;\u6ca1\u6709\u5c31\u767b\u8bb0\u3002\u76f8\u6bd4\u00a0string.Intern&#xff0c;\u5b83\u7684\u597d\u5904\u5168\u5728&#034;\u53ef\u63a7&#034;\u4e0a&#xff1a;\u5b57\u5178\u662f\u4f60\u81ea\u5df1\u7684&#xff0c;\u53ef\u4ee5\u5728\u5173\u5361\u5378\u8f7d\u3001\u5546\u57ce\u5173\u95ed\u3001\u534f\u8bae\u91cd\u8fde\u8fd9\u4e9b\u65f6\u673a\u6309\u524d\u7f00\u6216\u6309\u6574\u8868\u6e05\u7406&#xff0c;\u628a\u4e0d\u8be5\u5e38\u9a7b\u7684\u540d\u5b57\u653e\u56de\u5806\u91cc\u8ba9 GC \u5904\u7406\u3002\u8fd9\u4e5f\u6b63\u662f\u6ce8\u91ca\u91cc&#034;\u53ef\u6309\u9700\u6e05\u7406&#034;\u56db\u4e2a\u5b57\u7684\u542b\u4e49\u3002<\/p>\n<p>\u5b83\u7684\u4ee3\u4ef7\u540c\u6837\u8981\u6b63\u89c6\u3002\u7b2c\u4e00&#xff0c;\u5b57\u5178\u7684\u952e\u6301\u6709\u5b57\u7b26\u4e32\u5f15\u7528&#xff0c;\u6c60\u6709\u591a\u5927\u5e38\u9a7b\u5185\u5b58\u5c31\u6709\u591a\u5927&#xff0c;\u6e05\u7406\u7b56\u7565\u6ca1\u8bbe\u8ba1\u597d\u7b49\u4e8e\u81ea\u5df1\u9020\u4e86\u4e00\u4e2a\u53ea\u8fdb\u4e0d\u51fa\u7684\u9a7b\u7559\u6c60\u3002\u7b2c\u4e8c&#xff0c;TryGetValue\u00a0\u6709\u6563\u5217\u4e0e\u6bd4\u8f83\u6210\u672c&#xff0c;\u5b57\u7b26\u4e32\u5f88\u957f\u6216\u8c03\u7528\u6781\u9891\u7e41\u65f6\u8981\u7b97\u8fd9\u7b14\u8d26&#xff0c;\u5fc5\u8981\u65f6\u6539\u7528&#034;\u77ed\u5185\u5bb9\u505a\u952e&#034;\u7684\u4e24\u7ea7\u7ed3\u6784\u3002\u7b2c\u4e09&#xff0c;\u591a\u7ebf\u7a0b\u8bbf\u95ee\u9700\u8981\u52a0\u9501\u6216\u6362\u5e76\u53d1\u5b57\u5178&#xff0c;\u9501\u53c8\u5f15\u5165\u4e89\u7528&#xff0c;\u6c60\u5316\u8c03\u7528\u70b9\u6700\u597d\u96c6\u4e2d\u5728\u52a0\u8f7d\u671f\u4e0e\u521d\u59cb\u5316\u671f&#xff0c;\u800c\u4e0d\u662f\u6bcf\u5e27\u70ed\u8def\u5f84\u3002\u7b2c\u56db&#xff0c;Unity \u5173\u95ed\u57df\u91cd\u8f7d\u65f6\u9759\u6001\u6c60\u8de8\u573a\u666f\u5b58\u6d3b&#xff0c;\u4e0d\u5173\u5219\u6bcf\u6b21\u8fdb\u64ad\u653e\u6a21\u5f0f\u90fd\u91cd\u5efa&#xff0c;\u4e24\u79cd\u884c\u4e3a\u5bf9\u5185\u5b58\u66f2\u7ebf\u5f71\u54cd\u4e0d\u540c&#xff0c;\u505a\u771f\u673a\u5185\u5b58\u8bc4\u4f30\u8981\u628a\u8fd9\u4e2a\u53d8\u91cf\u56fa\u5b9a\u4e0b\u6765\u3002<\/p>\n<h4 id=\"73-\u4ec0\u4e48\u65f6\u5019\u4e0d\u503c\u5f97\u6c60\u5316\">7.3 \u4ec0\u4e48\u65f6\u5019\u4e0d\u503c\u5f97\u6c60\u5316<\/h4>\n<p>\u4e09\u4e2a\u4fe1\u53f7\u51fa\u73b0\u4efb\u4f55\u4e00\u4e2a\u5c31\u8be5\u505c\u624b\u3002\u4e00\u662f\u5b57\u7b26\u4e32\u79cd\u7c7b\u65e0\u754c\u589e\u957f&#xff0c;\u6bd4\u5982\u628a\u73a9\u5bb6\u6635\u79f0\u3001\u804a\u5929\u5185\u5bb9\u3001\u52a8\u6001\u751f\u6210\u7684\u8def\u5f84\u585e\u8fdb\u6c60&#xff0c;\u6c60\u672c\u8eab\u4f1a\u65e0\u9650\u81a8\u80c0\u3002\u4e8c\u662f\u5b57\u7b26\u4e32\u5f88\u957f&#xff0c;\u6c60\u5316\u7701\u4e0b\u7684\u5206\u914d\u88ab\u5b57\u5178\u5b58\u50a8\u6210\u672c\u53cd\u8d85\u3002\u4e09\u662f\u8c03\u7528\u70b9\u5728\u6bcf\u5e27\u70ed\u8def\u5f84\u4e14\u65e0\u9501\u4e0d\u53ef\u884c&#xff0c;\u4e3a\u7701\u51e0\u4e2a\u5c0f\u5206\u914d\u5f15\u5165\u9501\u4e89\u7528\u901a\u5e38\u5f97\u4e0d\u507f\u5931\u3002\u6c60\u5316\u7684\u6b63\u786e\u5fc3\u6001\u662f\u628a\u5b83\u5f53&#034;\u6709\u9650\u8bcd\u5178&#034;&#xff0c;\u670d\u52a1\u679a\u4e3e\u540d\u4e0e\u914d\u7f6e\u540d\u8fd9\u7c7b\u5929\u7136\u5c01\u95ed\u7684\u96c6\u5408\u3002<\/p>\n<p>\u518d\u8865\u4e09\u6761\u4ee3\u7801\u5ba1\u67e5\u65f6\u503c\u5f97\u76ef\u7684\u6a21\u5f0f&#xff0c;\u5e76\u9644\u91cf\u7ea7&#xff1a;&#034;&#034; &#043; x\u00a0\u4ea7\u751f 2 \u4e2a\u4e34\u65f6\u5b57\u7b26\u4e32&#xff08;\u7a7a\u4e32\u5e38\u91cf\u672c\u8eab\u4e0d\u5206\u914d&#xff0c;x\u00a0\u7684 ToString \u52a0\u4e00\u6b21 Concat \u5404\u4e00\u4e2a&#xff09;&#xff1b;x &#043; &#034;, &#034; &#043; y\u00a0\u4ea7\u751f 3 \u4e2a&#xff08;\u4e24\u6b21 ToString \u6216\u5df2\u6709\u4e32\u52a0\u4e00\u6b21\u4e2d\u95f4 Concat \u52a0\u4e00\u6b21\u6700\u7ec8 Concat&#xff0c;\u89c6\u9879\u7684\u9759\u6001\u7c7b\u578b\u6d6e\u52a8&#xff09;&#xff1b;\u5faa\u73af\u5185\u62fc\u63a5\u662f O(n\u00b2) \u5b57\u7b26\u590d\u5236\u3002\u8fd9\u4e09\u6761\u53ef\u4ee5\u76f4\u63a5\u6284\u8fdb\u56e2\u961f\u7684\u9759\u6001\u626b\u63cf\u89c4\u5219\u6216 Code Review \u6e05\u5355\u3002<\/p>\n<h3 id=\"\u516b-\u7f16\u7801\u8f6c\u6362utf8-\u5f80\u8fd4\u7684\u53cc\u500d\u5206\u914d\">\u516b\u3001\u7f16\u7801\u8f6c\u6362&#xff1a;UTF8 \u5f80\u8fd4\u7684\u53cc\u500d\u5206\u914d<\/h3>\n<p>\u5b57\u7b26\u4e32\u4e0e\u5b57\u8282\u6570\u7ec4\u4e4b\u95f4\u7684\u8f6c\u6362\u662f\u53e6\u4e00\u7c7b\u9690\u853d\u5206\u914d&#xff0c;\u51fa\u73b0\u5728\u5b58\u6863\u3001\u7f51\u7edc\u3001\u539f\u751f\u63d2\u4ef6\u4ea4\u4e92\u3001\u6587\u4ef6\u8bfb\u5199\u8fd9\u4e9b\u5730\u65b9\u3002Encoding.UTF8.GetBytes(string)\u00a0\u5728\u5806\u4e0a\u5206\u914d\u4e00\u4e2a\u00a0byte[]\u00a0\u5e76\u628a UTF-8 \u5b57\u8282\u5199\u8fdb\u53bb&#xff1b;Encoding.UTF8.GetString(byte[])\u00a0\u53cd\u8fc7\u6765\u5206\u914d\u4e00\u4e2a\u65b0 string\u3002\u4e00\u6b21\u5f80\u8fd4&#xff0c;\u5b57\u7b26\u4e32\u548c\u5b57\u8282\u6570\u7ec4\u5404\u6765\u4e00\u904d&#xff0c;\u8c01\u90fd\u6ca1\u7701\u3002<\/p>\n<p>\/\/ \u574f&#xff1a;\u6bcf\u6b21\u6536\u53d1\u5305\u90fd\u65b0\u5efa\u7f13\u51b2\u533a\u5e76\u5f80\u8fd4\u8f6c\u6362<br \/>\nbyte[] Send(string payload)<br \/>\n{<br \/>\n    byte[] bytes &#061; Encoding.UTF8.GetBytes(payload);   \/\/ \u5206\u914d byte[]<br \/>\n    WriteToSocket(bytes);                             \/\/ \u53d1\u9001<br \/>\n    return bytes;                                     \/\/ \u7528\u5b8c\u5373\u5f03&#xff0c;\u4e0b\u4e00\u8f6e\u518d\u6765<br \/>\n}<\/p>\n<p>\/\/ \u597d&#xff1a;\u7f13\u51b2\u533a\u590d\u7528&#xff0c;\u53ea\u5728\u5185\u5bb9\u53d8\u5316\u65f6\u91cd\u65b0\u7f16\u7801<br \/>\nreadonly byte[] _sendBuffer &#061; new byte[8 * 1024];<br \/>\nint _sendLength;<\/p>\n<p>void PrepareSend(string payload)<br \/>\n{<br \/>\n    _sendLength &#061; Encoding.UTF8.GetBytes(<br \/>\n        payload.AsSpan(), _sendBuffer);   \/\/ \u7f16\u7801\u8fdb\u5df2\u6709\u7f13\u51b2\u533a&#xff0c;\u65e0 byte[] \u5206\u914d<br \/>\n    WriteToSocket(_sendBuffer, _sendLength);<br \/>\n}<\/p>\n<p>\u9010\u6bb5\u89e3\u8bfb\u3002\u574f\u7248\u672c\u6bcf\u6b21\u8c03\u7528\u4e24\u4e2a\u5206\u914d\u89c6\u89d2&#xff1a;GetBytes(string)\u00a0\u8fd4\u56de\u5168\u65b0\u6570\u7ec4&#xff0c;\u5176\u5bb9\u91cf\u7531\u5b57\u7b26\u4e32\u957f\u5ea6\u51b3\u5b9a&#xff0c;\u5185\u5bb9\u4e00\u53d8\u6570\u7ec4\u5c31\u4f5c\u5e9f&#xff1b;\u5728\u9ad8\u9891\u6536\u53d1\u7684\u573a\u666f\u91cc\u8fd9\u5c31\u662f\u6bcf\u5305\u4e00\u6b21\u7684\u6570\u7ec4\u5783\u573e&#xff0c;\u5305\u5927\u4e00\u70b9\u8fd8\u4f1a\u903c\u8fd1 LOH \u9608\u503c&#xff08;.NET \u7cfb\u8fd0\u884c\u65f6\u5927\u5bf9\u8c61\u9608\u503c\u4e3a 85,000 \u5b57\u8282&#xff0c;Unity \u7684 Boehm \u8def\u5f84\u4e0a\u5927\u6570\u7ec4\u540c\u6837\u662f\u6700\u4e0d\u5e0c\u671b\u9891\u7e41\u91cd\u751f\u7684\u5bf9\u8c61\u7c7b\u522b&#xff09;\u3002\u597d\u7248\u672c\u628a\u7f13\u51b2\u533a\u63d0\u4e3a\u5b57\u6bb5&#xff0c;GetBytes\u00a0\u8c03\u7528\u6539\u7528\u63a5\u6536\u7f13\u51b2\u533a\u7684\u91cd\u8f7d&#xff0c;\u7f16\u7801\u7ed3\u679c\u76f4\u63a5\u5199\u8fdb\u5df2\u6709\u6570\u7ec4&#xff0c;\u8fd4\u56de\u503c\u662f\u5b9e\u9645\u5199\u5165\u7684\u5b57\u8282\u6570\u800c\u4e0d\u662f\u65b0\u6570\u7ec4\u3002\u8fd9\u5957\u6539\u6cd5\u7684\u524d\u63d0\u662f\u5bf9\u6700\u5927\u957f\u5ea6\u6709\u628a\u63e1&#xff0c;\u8d85\u957f\u5185\u5bb9\u9700\u8981\u6269\u5bb9\u7b56\u7565\u914d\u5408&#xff0c;\u5b81\u53ef\u5206\u5e27\u6216\u5206\u7247\u53d1\u9001&#xff0c;\u4e5f\u4e0d\u8981\u9000\u56de\u6bcf\u5305\u65b0\u5efa\u3002<\/p>\n<p>\u540c\u4e00\u4e2a\u6a21\u5f0f\u8fd8\u6709\u51e0\u4e2a\u53d8\u4f53&#xff1a;\u4ece\u539f\u751f\u63d2\u4ef6\u53d6\u5b57\u7b26\u4e32\u65f6&#xff0c;\u4f18\u5148\u8ba9\u5bf9\u65b9\u5199\u5165\u9884\u5206\u914d\u7684\u00a0byte[]\u00a0\u6216\u00a0NativeArray&lt;byte&gt;&#xff0c;\u81ea\u5df1\u518d\u89e3\u7801\u4e00\u6b21&#xff1b;\u9ad8\u9891\u5c0f\u6587\u4ef6\u8bfb\u53d6\u590d\u7528\u7f13\u51b2\u533a\u52a0\u6d41\u5f0f\u8bfb\u53d6&#xff1b;\u4e0e\u6587\u672c\u534f\u8bae\u6253\u4ea4\u9053\u65f6&#xff0c;\u628a&#034;\u89e3\u7801\u51fa\u6765\u7684 string&#034;\u4e5f\u7eb3\u5165\u5206\u914d\u9884\u7b97&#xff0c;UTF-8 \u5230 UTF-16 \u7684\u8f6c\u6362\u672c\u8eab\u5c31\u662f\u4e00\u6b21\u5b57\u7b26\u4e32\u5206\u914d\u3002\u8fd9\u4e9b\u8def\u5f84\u4e0a\u7684 API \u968f Unity \u7248\u672c\u53d8\u5316&#xff0c;\u5224\u65ad\u6807\u51c6\u4e0d\u53d8&#xff1a;\u770b Profiler \u91cc\u6709\u6ca1\u6709\u4f60\u4e0d\u8ba4\u8bc6\u7684 byte \u6570\u7ec4\u4e0e\u5b57\u7b26\u4e32\u6210\u5bf9\u51fa\u73b0\u3002<\/p>\n<h3 id=\"\u4e5d-textmeshpro-\u4e0e-ui-\u6587\u672c\u7684\u5e38\u89c1\u8bef\u7528\">\u4e5d\u3001TextMeshPro \u4e0e UI \u6587\u672c\u7684\u5e38\u89c1\u8bef\u7528<\/h3>\n<p>UI \u6587\u672c\u662f\u5b57\u7b26\u4e32\u5206\u914d\u7684\u91cd\u707e\u533a&#xff0c;\u56e0\u4e3a\u5b83\u540c\u65f6\u8e29\u4e2d&#034;\u6bcf\u5e27\u62fc\u63a5&#034;\u548c&#034;\u6539\u4e00\u4e2a\u5b57\u89e6\u53d1\u6574\u5757\u91cd\u5efa&#034;\u4e24\u4ef6\u4e8b\u3002\u5148\u5206\u6e05\u4e24\u7c7b\u6210\u672c&#xff1a;\u5b57\u7b26\u4e32\u5206\u914d\u662f GC \u95ee\u9898&#xff0c;\u6587\u672c\u7f51\u683c\u91cd\u5efa\u662f CPU \u95ee\u9898&#xff0c;\u4e24\u8005\u90fd\u62d6\u7d2f\u5e27\u65f6\u95f4&#xff0c;\u6cbb\u7597\u65b9\u6848\u4e0d\u540c&#xff0c;\u672c\u6587\u53ea\u8d1f\u8d23\u524d\u8005&#xff0c;\u540e\u8005\u89c1 08-09 \u4e0e 08-10\u3002<\/p>\n<p>\u5e38\u89c1\u8bef\u7528\u4e00&#xff1a;\u6bcf\u5e27\u65e0\u6761\u4ef6\u8d4b\u503c\u3002scoreText.text &#061; score.ToString()\u00a0\u5728\u5206\u6570\u6ca1\u53d8\u7684\u5e27\u91cc\u4e5f\u7167\u505a\u4e00\u904d ToString \u4e0e\u5c5e\u6027\u8d4b\u503c\u3002\u5c5e\u6027\u8d4b\u503c\u672c\u8eab\u8fd8\u4f1a\u89e6\u53d1 TMP \u5185\u90e8\u7684\u89e3\u6790\u6d41\u7a0b&#xff0c;\u5185\u5bb9\u4e0e\u4e0a\u6b21\u76f8\u540c\u4e5f\u8981\u8d70\u4e00\u904d\u68c0\u67e5\u3002\u6539\u6cd5\u662f\u7f13\u5b58\u4e0a\u6b21\u503c&#xff0c;\u5185\u5bb9\u53d8\u5316\u624d\u66f4\u65b0&#xff1a;<\/p>\n<p>int _shownScore &#061; int.MinValue;<\/p>\n<p>void RefreshScore(int score)<br \/>\n{<br \/>\n    if (score &#061;&#061; _shownScore) return;      \/\/ \u5185\u5bb9\u6ca1\u53d8&#xff1a;\u4e0d ToString&#xff0c;\u4e0d\u8d4b\u503c<br \/>\n    _shownScore &#061; score;<br \/>\n    _scoreText.text &#061; score.ToString();    \/\/ \u53d8\u5316\u5e27\u624d\u627f\u62c5\u8fd9\u4e00\u6b21\u5206\u914d<br \/>\n}<\/p>\n<p>\u9010\u6bb5\u89e3\u8bfb\u3002\u8fd9\u4e2a\u5b88\u536b\u53ea\u6709\u4e09\u884c&#xff0c;\u780d\u6389\u7684\u5374\u662f&#034;\u6bcf\u5e27\u4e00\u6b21 ToString \u52a0\u4e00\u6b21\u5c5e\u6027\u8d4b\u503c&#034;\u7684\u56fa\u5b9a\u5f00\u9500\u3002int.MinValue\u00a0\u4f5c\u4e3a\u521d\u503c\u662f\u4e3a\u4e86\u4fdd\u8bc1\u9996\u5e27\u5fc5\u7136\u5237\u65b0&#xff0c;\u907f\u514d UI \u663e\u793a\u521d\u503c\u4e0e\u903b\u8f91\u503c\u5de7\u5408\u76f8\u540c\u65f6\u7684\u663e\u793a\u9519\u8bef\u3002\u5b88\u536b\u6a21\u5f0f\u5bf9\u6240\u6709\u9ad8\u9891 UI \u5b57\u6bb5\u901a\u7528&#xff1a;\u8840\u91cf\u3001\u5f39\u836f\u3001\u51b7\u5374\u5012\u8ba1\u65f6\u3001\u7f51\u7edc\u5ef6\u8fdf&#xff0c;\u90fd\u6309&#034;\u53d8\u5316\u624d\u5199&#034;\u6539\u9020\u3002<\/p>\n<p>\u5e38\u89c1\u8bef\u7528\u4e8c&#xff1a;\u7528\u62fc\u63a5\u66f4\u65b0\u590d\u5408\u6587\u672c\u3002hpText.text &#061; $&#034;{cur}\/{max} HP&#034;\u00a0\u6bcf\u5e27\u6267\u884c\u65f6&#xff0c;\u63d2\u503c\u7684\u88c5\u7bb1\u4e0e\u7ed3\u679c\u4e32\u524d\u9762\u5df2\u7ecf\u7b97\u8fc7\u8d26\u3002TMP \u63d0\u4f9b\u4e86\u5e26\u53c2\u6570\u7684\u00a0SetText\u00a0\u91cd\u8f7d\u4e0e\u76f4\u63a5\u63a5\u6536\u00a0StringBuilder\u00a0\u7684\u91cd\u8f7d&#xff0c;\u524d\u8005\u628a\u683c\u5f0f\u5316\u6536\u8fdb TMP \u5185\u90e8&#xff0c;\u540e\u8005\u8ba9\u683c\u5f0f\u5316\u7ed3\u679c\u76f4\u63a5\u843d\u5728\u4f60\u590d\u7528\u7684\u7f13\u51b2\u533a\u91cc&#xff0c;\u8c03\u7528\u65b9\u4e0d\u518d\u4ea7\u51fa\u4e2d\u95f4\u5b57\u7b26\u4e32\u3002\u5177\u4f53\u91cd\u8f7d\u96c6\u5408\u968f TMP \u5305\u7248\u672c\u53d8\u5316&#xff0c;\u4ee5\u4f60\u5de5\u7a0b\u91cc\u5b9e\u9645\u7684 API \u9762\u4e3a\u51c6&#xff0c;\u5224\u65ad\u65b9\u6cd5\u8fd8\u662f Profiler&#xff1a;\u5bf9\u540c\u4e00\u5904\u66f4\u65b0\u6362\u5199\u6cd5&#xff0c;\u770b GC Allocated In Frame \u7684\u5dee\u503c\u3002<\/p>\n<p>\u5e38\u89c1\u8bef\u7528\u4e09&#xff1a;\u628a\u957f\u6587\u672c\u6574\u4f53\u91cd\u5efa\u3002\u804a\u5929\u8bb0\u5f55\u3001\u6218\u6597\u65e5\u5fd7\u8fd9\u7c7b\u6eda\u52a8\u6587\u672c&#xff0c;\u6bcf\u6765\u4e00\u6761\u65b0\u6d88\u606f\u5c31\u00a0oldText &#043; &#034;\\\\n&#034; &#043; newText&#xff0c;\u62fc\u63a5\u672c\u8eab O(n\u00b2)&#xff0c;\u62fc\u51fa\u6765\u7684\u6574\u4e32\u6bcf\u6b21\u90fd\u8981 TMP \u91cd\u65b0\u89e3\u6790\u4e0e\u91cd\u5efa\u7f51\u683c\u3002\u6b63\u8def\u662f\u6309\u884c\u7ba1\u7406&#xff1a;\u7528\u7f13\u51b2\u7684 StringBuilder \u751f\u6210\u672c\u6b21\u8ffd\u52a0\u7684\u5355\u884c&#xff0c;\u6216\u8005\u7528 TMP \u7684\u8ffd\u52a0\u63a5\u53e3\u4e0e\u5bcc\u6587\u672c\u6807\u7b7e\u5c40\u90e8\u66f4\u65b0&#xff0c;\u628a&#034;\u65b0\u6d88\u606f&#034;\u7684\u5b57\u7b26\u4e32\u6210\u672c\u63a7\u5236\u5728\u5355\u884c\u957f\u5ea6&#xff0c;\u800c\u4e0d\u662f\u6574\u9875\u957f\u5ea6\u3002<\/p>\n<h3 id=\"\u5341-\u91cf\u7ea7\u4f30\u7b97\u4e0e\u98ce\u9669\u5bf9\u7167\u8868\">\u5341\u3001\u91cf\u7ea7\u4f30\u7b97\u4e0e\u98ce\u9669\u5bf9\u7167\u8868<\/h3>\n<p>\u628a\u5168\u6587\u7684\u9677\u9631\u6536\u8fdb\u4e00\u5f20\u8868&#xff0c;\u6700\u53f3\u5217\u7684\u98ce\u9669\u5206\u7ea7\u4f9b\u6392\u671f\u53c2\u8003&#xff0c;\u6240\u6709\u5b57\u8282\u6570\u4e3a\u5178\u578b\u4f30\u7b97&#xff0c;\u5b9e\u6d4b\u4ee5 Profiler \u4e3a\u51c6&#xff1a;<\/p>\n<table>\n<tr>\u64cd\u4f5c\u5206\u914d\u5728\u54ea\u4ea7\u751f\u5178\u578b\u4f30\u7b97\u6539\u6cd5\u98ce\u9669<\/tr>\n<tbody>\n<tr>\n<td>\u5faa\u73af\u5185\u00a0s &#043;&#061; x&#xff08;100 \u9879&#xff09;<\/td>\n<td>\u6bcf\u8f6e Concat \u52a0 ToString<\/td>\n<td>\u7ea6 200 \u4e2a\u77ed\u4e32&#xff0c;\u5b57\u7b26\u590d\u5236 O(n\u00b2)<\/td>\n<td>StringBuilder \u9884\u4f30\u5bb9\u91cf<\/td>\n<td>\u9ad8<\/td>\n<\/tr>\n<tr>\n<td>a &#043; b &#043; c &#043; d&#xff08;4 \u9879\u4ee5\u4e0a&#xff09;<\/td>\n<td>params string[]\u00a0\u6570\u7ec4\u52a0\u7ed3\u679c\u4e32<\/td>\n<td>\u6bcf\u6b21 2 \u4e2a\u5bf9\u8c61<\/td>\n<td>\u62c6\u6210\u4e24\u6b21 3 \u9879\u5185\u62fc\u63a5\u6216\u7528 Join<\/td>\n<td>\u4f4e<\/td>\n<\/tr>\n<tr>\n<td>$&#034;{hp}\/{max}&#034;&#xff08;Unity \u8fd0\u884c\u65f6&#xff09;<\/td>\n<td>\u683c\u5f0f\u5316\u6570\u7ec4\u3001\u88c5\u7bb1\u3001\u7ed3\u679c\u4e32<\/td>\n<td>\u6bcf\u6b21 2~4 \u4e2a\u5bf9\u8c61&#xff08;\u793a\u4f8b\u91cf\u7ea7&#xff09;<\/td>\n<td>StringBuilder.Append \u91cd\u8f7d<\/td>\n<td>\u4e2d<\/td>\n<\/tr>\n<tr>\n<td>string.Format\u00a0\u5e26\u503c\u7c7b\u578b\u53c2\u6570<\/td>\n<td>object[]\u00a0\u52a0\u88c5\u7bb1\u52a0\u7ed3\u679c\u4e32<\/td>\n<td>\u6bcf\u6b21 4 \u4e2a\u8d77&#xff08;\u793a\u4f8b\u91cf\u7ea7&#xff09;<\/td>\n<td>\u540c\u4e0a&#xff0c;\u6216\u6362 Concat \u52a0 ToString<\/td>\n<td>\u4e2d<\/td>\n<\/tr>\n<tr>\n<td>\u5faa\u73af\u5185\u00a0Substring\u00a0\u5207\u5927\u4e32<\/td>\n<td>\u65b0 string \u52a0\u6574\u6bb5\u5b57\u7b26\u590d\u5236<\/td>\n<td>\u6bcf\u6b21\u7ea6 24B \u52a0 2\u00d7\u7a97\u53e3\u957f\u5ea6<\/td>\n<td>\u7d22\u5f15\u5316\u6216 Span \u5207\u7247<\/td>\n<td>\u9ad8<\/td>\n<\/tr>\n<tr>\n<td>\u6bcf\u5e27\u00a0int.ToString<\/td>\n<td>\u77ed\u547d\u5b57\u7b26\u4e32<\/td>\n<td>\u6bcf\u6b21\u7ea6 24~32B&#xff08;\u5178\u578b\u4f30\u7b97&#xff09;<\/td>\n<td>\u7f13\u5b58\u4e0a\u6b21\u503c&#xff0c;\u53d8\u5316\u624d\u8f6c<\/td>\n<td>\u4e2d<\/td>\n<\/tr>\n<tr>\n<td>\u6bcf\u5e27\u00a0sb.ToString()<\/td>\n<td>\u7ed3\u679c\u5b57\u7b26\u4e32<\/td>\n<td>\u6bcf\u6b21\u4e00\u4e2a\u65b0\u4e32<\/td>\n<td>\u4ec5\u5728\u9700\u8981 string \u7684\u8fb9\u754c\u8c03\u7528<\/td>\n<td>\u4e2d<\/td>\n<\/tr>\n<tr>\n<td>Encoding.UTF8.GetBytes\u00a0\/\u00a0GetString<\/td>\n<td>\u65b0\u00a0byte[]\u00a0\u4e0e\u65b0 string<\/td>\n<td>\u5404\u7ea6 2\u00d7\u81ea\u8eab\u5b57\u8282\u91cf<\/td>\n<td>\u7f16\u7801\u8fdb\u590d\u7528\u7f13\u51b2\u533a<\/td>\n<td>\u9ad8<\/td>\n<\/tr>\n<tr>\n<td>\u6bcf\u5e27\u00a0text &#061; \u4efb\u610f\u65b0\u4e32<\/td>\n<td>\u8c03\u7528\u65b9\u5b57\u7b26\u4e32\u52a0 TMP \u89e3\u6790<\/td>\n<td>\u5b57\u7b26\u4e32\u4e00\u6b21&#xff0c;CPU \u6210\u672c\u53e6\u8ba1<\/td>\n<td>\u53d8\u5316\u624d\u8d4b\u503c&#xff0c;\u7f13\u5b58\u4e0a\u6b21\u4e32<\/td>\n<td>\u9ad8<\/td>\n<\/tr>\n<tr>\n<td>\u9ad8\u9891\u91cd\u590d\u679a\u4e3e\u540d<\/td>\n<td>\u540c\u5185\u5bb9\u5b57\u7b26\u4e32\u53cd\u590d\u521b\u5efa<\/td>\n<td>\u6bcf\u6b21\u4e00\u4e2a\u77ed\u4e32<\/td>\n<td>\u5e94\u7528\u7ea7\u6c60\u6216 Intern<\/td>\n<td>\u4f4e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8868\u91cc\u98ce\u9669\u5206\u7ea7\u7684\u53e3\u5f84\u662f&#034;\u5728\u6bcf\u5e27\u8def\u5f84\u51fa\u73b0\u65f6\u5bf9 GC \u5361\u987f\u7684\u8d21\u732e\u9884\u671f&#034;&#xff1a;\u9ad8\u8868\u793a\u5355\u70b9\u5c31\u8db3\u4ee5\u63a8\u52a8 GC \u9891\u7387\u4e0a\u5347&#xff0c;\u4e2d\u8868\u793a\u53e0\u52a0\u540e\u53ef\u89c2&#xff0c;\u4f4e\u8868\u793a\u4e3b\u8981\u5728\u8d85\u9ad8\u9891\u6216\u8d85\u957f\u5b57\u7b26\u4e32\u65f6\u624d\u9700\u8981\u5904\u7406\u3002\u6392\u4f18\u5316\u987a\u5e8f\u65f6\u5148\u626b&#034;\u9ad8&#034;&#xff0c;\u518d\u770b Profiler \u91cc\u5b9e\u9645\u7684\u5206\u914d\u70ed\u70b9&#xff0c;\u4e0d\u8981\u6309\u4ee3\u7801\u884c\u6570\u5e73\u5747\u7528\u529b\u3002<\/p>\n<h3 id=\"\u5341\u4e00-\u5e38\u89c1\u8bef\u533a\u4e0e\u53cd\u6a21\u5f0f\">\u5341\u4e00\u3001\u5e38\u89c1\u8bef\u533a\u4e0e\u53cd\u6a21\u5f0f<\/h3>\n<p>\u8bef\u533a\u4e00&#xff1a;\u5b57\u7b26\u4e32\u5206\u914d\u5c0f&#xff0c;\u5355\u4e2a\u4e0d\u5fc3\u75bc&#xff0c;\u6240\u4ee5\u5148\u4e0d\u7ba1\u3002<br \/>\n\u9519\u8bef\u505a\u6cd5\u662f\u770b\u5230 Profiler \u91cc\u6bcf\u6b21\u53ea\u6709\u4e8c\u4e09\u5341\u5b57\u8282\u7684\u5b57\u7b26\u4e32\u5c31\u8df3\u8fc7&#xff0c;\u53ea\u8ffd\u5927\u5bf9\u8c61\u3002\u4e3a\u4ec0\u4e48\u9519&#xff1a;GC \u7684\u89e6\u53d1\u770b\u7684\u662f\u5206\u914d\u901f\u7387\u7684\u7d2f\u79ef&#xff0c;\u4e0d\u662f\u5355\u6b21\u5927\u5c0f\u3002\u6bcf\u5e27 300 \u6b21\u4e8c\u5341\u51e0\u5b57\u8282\u7684\u5b57\u7b26\u4e32\u5206\u914d&#xff0c;\u4e00\u79d2\u949f\u5c31\u662f\u4e0a\u4e07\u6b21&#xff0c;Boehm \u4e0d\u5206\u4ee3&#xff0c;\u8fd9\u4e9b\u5783\u573e\u6bcf\u4e00\u6b21\u90fd\u8981\u53c2\u4e0e\u540e\u7eed\u7684\u5168\u5806\u6807\u8bb0\u4e0e\u6e05\u626b\u3002\u6b63\u786e\u505a\u6cd5\u662f\u5148\u6309&#034;\u6bcf\u5e27\u5b57\u8282\u603b\u91cf&#034;\u770b\u5b57\u7b26\u4e32\u7c7b\u5206\u914d\u7684\u5360\u6bd4&#xff0c;\u5360\u6bd4\u8fdb\u5165\u524d\u4e09\u518d\u52a8\u624b&#xff0c;\u4f46\u52a8\u8d77\u624b\u6765\u5c31\u8981\u6309\u672c\u6587\u6e05\u5355\u9010\u6761\u6e05\u3002<\/p>\n<p>\u8bef\u533a\u4e8c&#xff1a;StringBuilder \u662f\u4e07\u7075\u836f&#xff0c;\u6240\u6709\u62fc\u63a5\u90fd\u6362\u6210\u5b83\u3002<br \/>\n\u9519\u8bef\u505a\u6cd5\u662f\u628a\u4e00\u6b21\u6027\u7684\u4e24\u6bb5\u62fc\u63a5\u4e5f\u6539\u5199\u6210 new \u52a0 Append \u52a0 ToString\u3002\u4e3a\u4ec0\u4e48\u9519&#xff1a;StringBuilder \u5bf9\u8c61\u52a0\u7f13\u51b2\u533a\u6570\u7ec4\u672c\u8eab\u4e5f\u662f\u5206\u914d&#xff0c;\u5355\u6b21\u4e24\u4e09\u6bb5\u7684\u62fc\u63a5\u7528\u00a0&#043;\u00a0\u53ea\u4ea7\u751f\u4e00\u4e2a\u7ed3\u679c\u4e32&#xff0c;\u6362\u5de5\u5177\u53cd\u800c\u591a\u4ed8\u4e00\u4e2a\u4e2d\u95f4\u5bf9\u8c61\u3002\u6b63\u786e\u505a\u6cd5\u662f\u770b\u9891\u7387\u548c\u62fc\u63a5\u6bb5\u6570&#xff1a;\u5faa\u73af\u91cc\u3001\u591a\u6b21\u62fc\u63a5\u3001\u5bb9\u91cf\u53ef\u9884\u4f30\u7684\u573a\u666f\u4e0a StringBuilder&#xff1b;\u4e00\u6b21\u6027\u4f4e\u9891\u62fc\u63a5\u4fdd\u7559\u00a0&#043;\u00a0\u6216\u00a0$&#034;&#034;&#xff0c;\u628a\u7cbe\u529b\u632a\u53bb\u66f4\u9ad8\u6536\u76ca\u7684\u5206\u914d\u70b9\u3002<\/p>\n<p>\u8bef\u533a\u4e09&#xff1a;\u5b57\u7b26\u4e32\u6c60\u5316\u80fd\u7701\u5206\u914d&#xff0c;\u90a3\u5c31\u628a\u6240\u6709\u5b57\u7b26\u4e32\u90fd\u8fdb\u6c60\u3002<br \/>\n\u9519\u8bef\u505a\u6cd5\u662f\u628a\u804a\u5929\u5185\u5bb9\u3001\u73a9\u5bb6\u8f93\u5165\u3001\u52a8\u6001\u8def\u5f84\u5168\u90e8 Intern \u6216\u5165\u6c60\u3002\u4e3a\u4ec0\u4e48\u9519&#xff1a;\u6c60\u662f\u5e38\u9a7b\u5185\u5b58&#xff0c;\u65e0\u754c\u5185\u5bb9\u5165\u6c60\u7b49\u4e8e\u628a\u672c\u53ef\u56de\u6536\u7684\u5783\u573e\u53d8\u6210\u6c38\u4e45\u5c45\u6c11&#xff0c;\u5806\u6c34\u4f4d\u53ea\u5347\u4e0d\u964d&#xff0c;\u4f4e\u7aef\u673a\u4e0a\u8868\u73b0\u4e3a\u5185\u5b58\u6301\u7eed\u4e0a\u6da8\u76f4\u81f3\u8fdb\u7a0b\u88ab\u6740\u3002\u6b63\u786e\u505a\u6cd5\u662f\u53ea\u6c60\u5316\u5c01\u95ed\u96c6\u5408&#xff0c;\u7ed9\u6c60\u914d\u6e05\u7406\u65f6\u673a&#xff08;\u5173\u5361\u5378\u8f7d\u3001\u4f1a\u8bdd\u7ed3\u675f&#xff09;&#xff0c;\u5e76\u628a\u6c60\u7684\u5bb9\u91cf\u7eb3\u5165\u5185\u5b58\u9884\u7b97\u76d1\u63a7\u3002<\/p>\n<p>\u8bef\u533a\u56db&#xff1a;Editor \u91cc\u770b\u5230 0 B \u5206\u914d\u5c31\u8bf4\u660e\u6539\u5bf9\u4e86\u3002<br \/>\n\u9519\u8bef\u505a\u6cd5\u662f\u5728 Editor \u7684 Profiler \u91cc\u626b\u4e00\u773c\u6ca1\u6709 GC.Alloc \u5c31\u5ba3\u5e03\u5b8c\u5de5\u3002\u4e3a\u4ec0\u4e48\u9519&#xff1a;Editor \u4e0e\u771f\u673a\u7684\u811a\u672c\u540e\u7aef\u3001\u5b57\u7b26\u4e32\u5b9e\u73b0\u7ec6\u8282\u3001UI \u6e32\u67d3\u8def\u5f84\u90fd\u4e0d\u540c&#xff0c;Editor \u7684\u5206\u914d\u6570\u53ea\u80fd\u8bc1\u660e\u8def\u5f84\u8d70\u5230\u4e86&#xff0c;\u4e0d\u80fd\u8bc1\u660e\u771f\u673a\u8fbe\u6807\u3002\u6b63\u786e\u505a\u6cd5\u662f Development Build \u8fde\u771f\u673a&#xff0c;\u6539\u524d\u540e\u5404\u91c7\u4e00\u6bb5 GC Allocated In Frame \u5e8f\u5217\u505a\u5bf9\u6bd4\u3002<\/p>\n<h3 id=\"\u5341\u4e8c-\u5de5\u7a0b\u5b9e\u8df5\u51b3\u7b56\u6e05\u5355\">\u5341\u4e8c\u3001\u5de5\u7a0b\u5b9e\u8df5\u51b3\u7b56\u6e05\u5355<\/h3>\n<p>\u628a\u53ef\u6267\u884c\u7684\u52a8\u4f5c\u6309\u5b9e\u65bd\u987a\u5e8f\u5217\u51fa\u6765&#xff0c;\u6bcf\u6761\u90fd\u80fd\u76f4\u63a5\u8fdb\u4f60\u4eec\u56e2\u961f\u7684\u4f18\u5316\u6392\u671f&#xff1a;<\/p>\n<li>\u6253\u5f00 Profiler&#xff0c;\u6309 GC Allocated In Frame \u5b9a\u4f4d\u5b57\u7b26\u4e32\u7c7b\u5206\u914d\u5360\u6bd4\u9ad8\u7684\u8c03\u7528\u6808&#xff0c;\u5148\u6293\u6bcf\u5e27\u8def\u5f84\u4e0a\u7684&#xff0c;\u518d\u6293\u4e8b\u4ef6\u8def\u5f84\u4e0a\u7684\u3002<\/li>\n<li>\u5168\u5c40\u641c\u5faa\u73af\u5185\u7684\u00a0&#043;&#061;\u00a0\u5b57\u7b26\u4e32\u62fc\u63a5\u4e0e\u5faa\u73af\u5185\u00a0Substring&#xff0c;\u8fd9\u4e24\u7c7b\u6536\u76ca\u6700\u76f4\u63a5&#xff0c;\u6309\u7b2c\u4e09\u8282\u548c\u7b2c\u56db\u8282\u7684\u6539\u6cd5\u6e05\u96f6\u3002<\/li>\n<li>\u628a\u70ed\u8def\u5f84\u4e0a\u7684\u00a0string.Format\u00a0\u4e0e\u5e26\u503c\u7c7b\u578b\u53c2\u6570\u7684\u63d2\u503c\u9010\u4e2a\u6362\u6210 StringBuilder \u7684 Append \u91cd\u8f7d&#xff0c;\u987a\u624b\u780d\u6389\u88c5\u7bb1\u3002<\/li>\n<li>\u7ed9\u6240\u6709\u6bcf\u5e27\u8d4b\u503c\u7684 UI \u6587\u672c\u52a0&#034;\u53d8\u5316\u624d\u5199&#034;\u5b88\u536b&#xff0c;\u590d\u5408\u6587\u672c\u6539\u7528 SetText \u53c2\u6570\u91cd\u8f7d\u6216 StringBuilder \u91cd\u8f7d\u3002<\/li>\n<li>\u68c0\u67e5\u5b58\u6863\u3001\u7f51\u7edc\u3001\u539f\u751f\u4ea4\u4e92\u8def\u5f84\u4e0a\u7684 GetBytes \u4e0e GetString&#xff0c;\u786e\u8ba4\u7f13\u51b2\u533a\u662f\u590d\u7528\u7684\u3002<\/li>\n<li>\u4e3a\u679a\u4e3e\u540d\u3001\u914d\u7f6e\u952e\u8fd9\u7c7b\u5c01\u95ed\u5b57\u7b26\u4e32\u96c6\u5408\u8bc4\u4f30\u5e94\u7528\u7ea7\u6c60&#xff0c;\u914d\u597d\u6e05\u7406\u65f6\u673a&#xff0c;\u628a\u6c60\u5927\u5c0f\u7eb3\u5165\u5185\u5b58\u76d1\u63a7\u3002<\/li>\n<li>\u590d\u67e5\u56e2\u961f\u89c4\u8303&#xff1a;StringBuilder \u5fc5\u987b\u5b57\u6bb5\u6301\u6709\u3001Clear \u590d\u7528&#xff1b;\u65e5\u5fd7\u62fc\u63a5\u5fc5\u987b\u5728\u5f00\u5173\u5224\u65ad\u4e4b\u540e&#xff1b;\u7981\u6b62\u5728\u5c5e\u6027 getter \u91cc\u505a\u62fc\u63a5\u3002<\/li>\n<li>\u5168\u90e8\u6539\u5b8c\u540e\u8fde\u771f\u673a\u590d\u6d4b&#xff0c;\u8bb0\u5f55\u6539\u524d\u6539\u540e\u7684\u6bcf\u5e27\u5206\u914d\u91cf\u3001GC \u6b21\u6570\u4e0e P99 \u5e27\u65f6\u95f4\u3002<\/li>\n<p>\u7b2c 7 \u6761\u6700\u5bb9\u6613\u88ab\u8df3\u8fc7\u4e5f\u6700\u503c\u5f97\u575a\u6301&#xff1a;\u5b57\u7b26\u4e32\u5206\u914d\u70b9\u6563\u3001\u5f62\u6001\u6742&#xff0c;\u4e00\u8f6e\u4e13\u9879\u6e05\u7406\u6321\u4e0d\u4f4f\u56de\u6f6e&#xff0c;\u786c\u89c4\u5219\u8fdb Code Review \u6e05\u5355\u6bd4\u4e00\u6b21\u6027\u91cd\u6784\u7ba1\u7528\u3002<\/p>\n<h3 id=\"\u5341\u4e09-\u4e0e\u76f8\u5173\u7ae0\u8282\u7684\u5173\u7cfb\">\u5341\u4e09\u3001\u4e0e\u76f8\u5173\u7ae0\u8282\u7684\u5173\u7cfb<\/h3>\n<p>\u672c\u6587\u4e13\u6ce8\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u8fd9\u4e00\u6761\u7ebf&#xff0c;\u5728\u5168\u4e13\u680f\u91cc\u7684\u4f4d\u7f6e\u5982\u4e0b&#xff0c;\u76f8\u5173\u673a\u5236\u4e0d\u91cd\u590d\u5c55\u5f00&#xff0c;\u6309\u9700\u8df3\u8f6c&#xff1a;<\/p>\n<table>\n<tr>\u4e3b\u9898\u672c\u6587\u8986\u76d6\u66f4\u6df1\u7684\u5185\u5bb9\u5728<\/tr>\n<tbody>\n<tr>\n<td>\u4e0d\u53ef\u53d8\u6027\u4e0e\u62fc\u63a5\u5206\u914d<\/td>\n<td>\u7b2c\u4e8c\u3001\u4e09\u8282<\/td>\n<td>\u65e0\u9700\u5916\u8df3<\/td>\n<\/tr>\n<tr>\n<td>\u95ed\u5305\u4e0e\u533f\u540d\u51fd\u6570\u7684\u5806\u5206\u914d<\/td>\n<td>\u4ec5\u5728 lambda \u6355\u83b7\u5b57\u7b26\u4e32\u53d8\u91cf\u5904\u8f7b\u63d0<\/td>\n<td>08-03 \u95ed\u5305\u4e0e\u533f\u540d\u51fd\u6570<\/td>\n<\/tr>\n<tr>\n<td>\u88c5\u7bb1\u5982\u4f55\u53e0\u52a0\u8fdb ToString \u4e0e Format<\/td>\n<td>\u7b2c\u4e94\u8282\u8bb2\u73b0\u8c61\u4e0e\u6539\u6cd5<\/td>\n<td>08-04 \u88c5\u7bb1\u4e0e\u53cd\u5c04<\/td>\n<\/tr>\n<tr>\n<td>Span \u4e0e\u96f6\u5206\u914d\u6587\u672c\u5904\u7406<\/td>\n<td>\u7b2c\u56db\u3001\u516b\u8282\u7ed9\u65b9\u5411<\/td>\n<td>08-07 Span \u4e0e\u96f6\u5206\u914d\u7f16\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>Unity \u5404 API \u7684\u5206\u914d\u6e05\u5355<\/td>\n<td>\u7b2c\u4e5d\u8282\u53ea\u8c08 TMP<\/td>\n<td>08-08 Unity API \u7684 GC \u9677\u9631\u6e05\u5355<\/td>\n<\/tr>\n<tr>\n<td>GC \u4e3a\u4ec0\u4e48\u5bf9\u5c0f\u5206\u914d\u654f\u611f\u3001\u589e\u91cf GC \u4e0e\u788e\u7247<\/td>\n<td>\u7b2c\u4e8c\u8282\u63d0\u7ed3\u8bba<\/td>\n<td>03 \u67b6\u6784\u7bc7\u300106 \u6536\u96c6\u5668\u7bc7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u6837\u5206\u5de5\u7684\u539f\u56e0\u4e00\u53e5\u8bdd\u5e26\u8fc7&#xff1a;\u5b57\u7b26\u4e32\u95ee\u9898\u7684\u6839\u5b50\u5728\u5206\u914d\u6a21\u5f0f&#xff0c;\u5206\u914d\u51fa\u53bb\u4e4b\u540e GC \u600e\u4e48\u5904\u7406\u5f52\u6536\u96c6\u5668\u90a3\u51e0\u7bc7\u8bb2&#xff0c;\u6392\u67e5\u65f6\u4e24\u4ef6\u4e8b\u4e32\u8d77\u6765\u770b&#xff0c;\u5199\u4f5c\u65f6\u62c6\u5f00\u5199\u3002<\/p>\n<h3 id=\"\u672c\u7ae0\u603b\u7ed3\">\u672c\u7ae0\u603b\u7ed3<\/h3>\n<p>\u6536\u62e2\u5168\u6587\u7684\u8981\u70b9&#xff0c;\u6309\u91cd\u8981\u5ea6\u6392&#xff1a;<\/p>\n<li>\u5b57\u7b26\u4e32\u7684\u4e0d\u53ef\u53d8\u6027\u51b3\u5b9a\u4e86\u6bcf\u6b21&#034;\u4fee\u6539&#034;\u90fd\u662f\u5b8c\u6574\u7684\u5206\u914d\u52a0\u590d\u5236&#xff0c;\u70ed\u8def\u5f84\u4e0a\u7684\u5b57\u7b26\u4e32\u95ee\u9898\u672c\u8d28\u662f\u5206\u914d\u901f\u7387\u95ee\u9898\u3002<\/li>\n<li>\u62fc\u63a5\u7684\u8d26\u8981\u6309\u964d\u7ea7\u7ed3\u679c\u7b97&#xff1a;\u4e09\u9879\u4ee5\u5185\u662f\u5355\u6b21 Concat&#xff0c;\u56db\u9879\u4ee5\u4e0a\u591a\u4e00\u4e2a\u53c2\u6570\u6570\u7ec4&#xff0c;Unity \u8fd0\u884c\u65f6\u7684\u63d2\u503c\u5b57\u7b26\u4e32\u63a5\u8fd1 Format&#xff0c;\u5e26\u503c\u7c7b\u578b\u5c31\u53e0\u52a0\u88c5\u7bb1\u3002<\/li>\n<li>Substring \u590d\u5236\u7a97\u53e3\u5b57\u7b26&#xff0c;\u5207\u5c0f\u53d6\u5927\u65f6\u6d6a\u8d39\u6700\u660e\u663e&#xff0c;\u7d22\u5f15\u5316\u4e0e Span \u662f\u6839\u6cbb\u65b9\u5411\u3002<\/li>\n<li>StringBuilder \u628a\u8fc7\u7a0b\u5206\u914d\u6d88\u5230\u53ea\u5269\u7ed3\u679c\u4e32&#xff0c;\u590d\u7528\u9760\u5b57\u6bb5\u6301\u6709\u52a0 Clear&#xff0c;\u5bb9\u91cf\u9884\u4f30\u51b3\u5b9a\u5b83\u662f\u5426\u771f\u96f6\u6269\u5bb9\u3002<\/li>\n<li>\u6c60\u5316\u53ea\u670d\u52a1\u5c01\u95ed\u5b57\u7b26\u4e32\u96c6\u5408&#xff0c;Intern \u53ea\u8fdb\u4e0d\u51fa&#xff0c;\u5e94\u7528\u7ea7\u6c60\u8981\u914d\u6e05\u7406&#xff0c;\u65e0\u754c\u5185\u5bb9\u6c38\u4e0d\u5165\u6c60\u3002<\/li>\n<li>\u7f16\u7801\u8f6c\u6362\u4e0e TMP \u8d4b\u503c\u662f\u4e24\u7c7b\u5bb9\u6613\u6f0f\u8d26\u7684\u5206\u914d&#xff0c;\u7f13\u51b2\u533a\u590d\u7528\u548c\u53d8\u5316\u624d\u5199\u662f\u5bf9\u5e94\u7684\u4e24\u628a\u94a5\u5319\u3002<\/li>\n<p>\u4e00\u53e5\u8bdd\u8bb0\u5fc6\u70b9&#xff1a;\u5b57\u7b26\u4e32\u4f18\u5316\u4e0d\u62a0\u5355\u4e2a\u5b57\u8282&#xff0c;\u53ea\u62a0&#034;\u6bcf\u5e27\u5c11\u9020\u51e0\u4e2a\u5bf9\u8c61&#034;\u3002\u6309\u672c\u6587\u6e05\u5355\u6e05\u4e00\u904d\u70ed\u8def\u5f84\u7684\u5b57\u7b26\u4e32\u5206\u914d&#xff0c;\u518d\u62ff\u771f\u673a Profiler \u9a8c\u6536&#xff0c;GC \u5361\u987f\u91cc\u5c5e\u4e8e\u6587\u672c\u7684\u90a3\u4e00\u5757\u4f1a\u9000\u5230\u80cc\u666f\u566a\u58f0\u7684\u6c34\u5e73\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684 GC \u9677\u9631\u7bc7\u7ae0&#xff1a;08-\u6027\u80fd\u4f18\u5316\u7bc7 |\u00a0\u9605\u8bfb\u65f6\u95f4&#xff1a;\u7ea6 45 \u5206\u949f |\u00a0\u524d\u7f6e\u77e5\u8bc6&#xff1a;\u4e86\u89e3 C# \u5b57\u7b26\u4e32\u57fa\u672c\u64cd\u4f5c\u4e0e Unity Profiler \u7684 GC.Alloc \u7528\u6cd5\u4e00\u3001\u5f15\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c\u662f C# \u7a0b\u5e8f\u4e2d\u6700\u5e38\u89c1\u7684 GC \u5206\u914d\u6765\u6e90\u3002\u5b57\u7b26\u4e32\u7684\u4e0d\u53ef\u53d8\u6027\u5bfc\u81f4\u6bcf\u6b21\\&#8221;\u4fee\u6539\\&#8221;\u90fd\u521b\u5efa\u65b0\u5bf9\u8c61\u3002\u8fd9\u4e00\u6761\u51e0\u4e4e\u6bcf\u4e2a C# \u5f00\u53d1\u8005\u90fd\u80cc\u5f97\u51fa&#xff0c;\u4f46\u5728 Unity \u9879\u76ee\u91cc&#xff0c;\u5b83\u771f\u6b63\u54ac\u4eba\u7684\u5730\u65b9\u8fdc\u4e0d\u6b62\\&#8221;\u62fc\u63a5\u4ea7\u751f\u65b0\u5b57\u7b26\u4e32\\&#8221;\u8fd9\u4e00\u53e5\u8bdd&amp;#x<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[893,13178,11236,868,55,183],"topic":[],"class_list":["post-118384","post","type-post","status-publish","format-standard","hentry","category-server","tag-netcore","tag-1024---","tag-gc","tag-868","tag-c","tag-unity"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>08-01-\u4f18\u5316-\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684GC\u9677\u9631 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/118384.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"08-01-\u4f18\u5316-\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684GC\u9677\u9631 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684 GC \u9677\u9631\u7bc7\u7ae0&#xff1a;08-\u6027\u80fd\u4f18\u5316\u7bc7 |\u00a0\u9605\u8bfb\u65f6\u95f4&#xff1a;\u7ea6 45 \u5206\u949f |\u00a0\u524d\u7f6e\u77e5\u8bc6&#xff1a;\u4e86\u89e3 C# \u5b57\u7b26\u4e32\u57fa\u672c\u64cd\u4f5c\u4e0e Unity Profiler \u7684 GC.Alloc \u7528\u6cd5\u4e00\u3001\u5f15\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c\u662f C# \u7a0b\u5e8f\u4e2d\u6700\u5e38\u89c1\u7684 GC \u5206\u914d\u6765\u6e90\u3002\u5b57\u7b26\u4e32\u7684\u4e0d\u53ef\u53d8\u6027\u5bfc\u81f4\u6bcf\u6b21&quot;\u4fee\u6539&quot;\u90fd\u521b\u5efa\u65b0\u5bf9\u8c61\u3002\u8fd9\u4e00\u6761\u51e0\u4e4e\u6bcf\u4e2a C# \u5f00\u53d1\u8005\u90fd\u80cc\u5f97\u51fa&#xff0c;\u4f46\u5728 Unity \u9879\u76ee\u91cc&#xff0c;\u5b83\u771f\u6b63\u54ac\u4eba\u7684\u5730\u65b9\u8fdc\u4e0d\u6b62&quot;\u62fc\u63a5\u4ea7\u751f\u65b0\u5b57\u7b26\u4e32&quot;\u8fd9\u4e00\u53e5\u8bdd&amp;#x\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/118384.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-26T19:16:21+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/118384.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/118384.html\",\"name\":\"08-01-\u4f18\u5316-\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684GC\u9677\u9631 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-26T19:16:21+00:00\",\"dateModified\":\"2026-10-26T19:16:21+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/118384.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/118384.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/118384.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"08-01-\u4f18\u5316-\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684GC\u9677\u9631\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"08-01-\u4f18\u5316-\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684GC\u9677\u9631 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/118384.html","og_locale":"zh_CN","og_type":"article","og_title":"08-01-\u4f18\u5316-\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684GC\u9677\u9631 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684 GC \u9677\u9631\u7bc7\u7ae0&#xff1a;08-\u6027\u80fd\u4f18\u5316\u7bc7 |\u00a0\u9605\u8bfb\u65f6\u95f4&#xff1a;\u7ea6 45 \u5206\u949f |\u00a0\u524d\u7f6e\u77e5\u8bc6&#xff1a;\u4e86\u89e3 C# \u5b57\u7b26\u4e32\u57fa\u672c\u64cd\u4f5c\u4e0e Unity Profiler \u7684 GC.Alloc \u7528\u6cd5\u4e00\u3001\u5f15\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c\u662f C# \u7a0b\u5e8f\u4e2d\u6700\u5e38\u89c1\u7684 GC \u5206\u914d\u6765\u6e90\u3002\u5b57\u7b26\u4e32\u7684\u4e0d\u53ef\u53d8\u6027\u5bfc\u81f4\u6bcf\u6b21\"\u4fee\u6539\"\u90fd\u521b\u5efa\u65b0\u5bf9\u8c61\u3002\u8fd9\u4e00\u6761\u51e0\u4e4e\u6bcf\u4e2a C# \u5f00\u53d1\u8005\u90fd\u80cc\u5f97\u51fa&#xff0c;\u4f46\u5728 Unity \u9879\u76ee\u91cc&#xff0c;\u5b83\u771f\u6b63\u54ac\u4eba\u7684\u5730\u65b9\u8fdc\u4e0d\u6b62\"\u62fc\u63a5\u4ea7\u751f\u65b0\u5b57\u7b26\u4e32\"\u8fd9\u4e00\u53e5\u8bdd&amp;#x","og_url":"https:\/\/www.wsisp.com\/helps\/118384.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-26T19:16:21+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/118384.html","url":"https:\/\/www.wsisp.com\/helps\/118384.html","name":"08-01-\u4f18\u5316-\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684GC\u9677\u9631 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-26T19:16:21+00:00","dateModified":"2026-10-26T19:16:21+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/118384.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/118384.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/118384.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"08-01-\u4f18\u5316-\u5b57\u7b26\u4e32\u4e0e\u6587\u672c\u64cd\u4f5c\u7684GC\u9677\u9631"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/118384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=118384"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/118384\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=118384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=118384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=118384"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=118384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}