java 获取文件名长度,Java-性能问题;变量名和文件名长度「建议收藏」

大家好,我是知秋君,一个会写博客吟诗的知秋码农。今天说一说java 获取文件名长度,Java-性能问题;变量名和文件名长度「建议收藏」,希望能够帮助大家进步!!! Well just some questions about performance, but i think some of the questions are logical: - If i use variables with

大家好,我是知秋君,一个会写博客吟诗的知秋码农。今天说一说java 获取文件名长度,Java-性能问题;变量名和文件名长度「建议收藏」,希望能够帮助大家进步!!!

Well just some questions about performance, but i think some of the questions are logical:

- If i use variables with short names will be better/faster to process?

Example: "String s", will be better than "String superphrase".

- About the file names, if the file name is short will be faster to access it?

Example: (almost the same) filename.txt or f.txt.

Thanks to all guys, i really like to make my software as better as i can :)

解决方案

If i use variables with short names will be better/faster to process?

No. Variable names might not even be in your resulting bytecode. In the end of the day variables are mapped to registers/stack operands. Variable name is irrelevant. It's only for human beings. And they tend to prefer superPhrase over s.

if the file name is short will be faster to access it

No. Files, just like variables, are referenced using special identifiers (e.g. inodes). File name is only needed when opening/locating a file. And it's several orders of magnitude faster compared to actual file access. This applies equally to Java applications and other OS processes.

知秋君
上一篇 2024-07-03 15:31
下一篇 2024-07-03 15:31

相关推荐