Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Data | data type | Performance Badregexpmatcher requires Mailbot to convert input text from a character array to a string object, resulting in unnecessary object creation. However, the funny thing is that in order to make it easier to use input text, Badregexpmatcher immediately converts a string object to an array of characters, which not only generates another object, but also means that you dickens the results of the call to the original data provided by the calling program. Mailbot and Badregexpmatcher do not require a string object, and a string object seems to exist only for exchanging text data between components.
in the Badregexpmatcher example above, string is just a type for interchange, neither the calling program nor the invoked program needs to use data types for interchange to represent data, but they can easily convert it to other data types. Although the use of data types for Exchange when defining an interface can reduce complexity while maintaining flexibility, it sometimes leads to performance losses.
One of the most common examples of data types used for
is the JDBC ResultSet interface, where no interface to a database represents the results returned with JDBC resultset, but the JDBC driver can easily convert the results returned by the database to JDBC ResultSet type data. Similarly, there is no client software that uses DBC resultset data to represent data records, but you can convert resultset data to the desired data type without any difficulty. We can accept this "superfluous" in JDBC because it has the advantages of being standard and portability across databases. In any case, the loss of performance caused by data types for Exchange is a noteworthy issue.
in Regexpmatcher, using a String object to define an interface is less helpful for reducing complexity or increasing portability, and has a considerable impact on performance, which is not worth the candle. It is often tempting to use interchangeable types when designing interfaces, because it makes the interface look "clean", but you should be sure that your compromise is sensible. Sometimes ━━ like Regexpmatcher, callers can use a variety of input and output formats, and should consider how they can be more easily satisfied with their needs.
It is worth noting that quantifying the impact of the use of interchangeable types on performance is not an easy thing to do. If the code that invokes Badregexpmatcher is parsed, it assigns the Run-time library to create a string object for input, which is generated to meet the requirements of the badregexpmatcher. If you want to measure the real impact of a component on performance, you need to evaluate not only the resource utilization of the code, but also the resource utilization of the calling code and the code that calls back, and it is very difficult to use the standard profiling Tools to do the profiling work.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.