Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze temporary string 0GC solution OneString

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to analyze the temporary string 0GC solution OneString, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.

OneString is a 0 GC ToString solution. GC is generated when traditional numeric or bool variables are converted to string. Because string is immutable, each time you change the value of string, a new string is generated internally. If we need to print a value temporarily, using the system-provided ToString function will inevitably generate a new string. We don't really need to save the value of this string, just to print it, which is a result we don't want to see. So it would be nice if there was a temporary string that was automatically recycled and reused after we used it, and no GC was generated. OneString is such a solution. However, it is important to note that the values in the Text component of UGUI, which need to be used to display the use, do not use this scheme, because the value of Text will be modified.

Characteristics

0 GC:To String does not produce GC.

Support int, long, float, double, bool and so on.

Support to set the precision of floating-point numbers. The default is to retain two decimal places.

Easy to use: just use the ToOneString () function, which returns a temporary string.

Support for extension and modification.

Contains the complete code and demo scenario.

Installation

Player Settings: check Allow 'unsafe' Code.

You can just use ToOneString (), which returns a temporary string string.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report