简体   繁体   English

Linux本机配置文件格式的读取效率

[英]Linux native config file format read efficiency

Is there a common practice on reading linux config files in a native format efficiently? 是否有有效地以本机格式读取linux配置文件的常见做法? Files are handled as streams, hence I guess the standard way to lookup by parsing is in O(n*m) (Let n lines, m avg line length). 文件被作为流处理,因此我想通过解析来查找的标准方法是O(n * m)(让n行,m avg行长)。 Is it common practice to build search trees from config files, or has this already been implemented, by eg QSettings? 从配置文件构建搜索树是常见的做法,还是已经通过QSettings实现了?

Why is this a problem? 为什么这是个问题? QSettings usually has very few kb of data, which can be loaded and parsed in a fraction of time. QSettings通常只有很少的kb数据,可以在很短的时间内加载和解析数据。 You don't really need to care about it. 您真的不需要关心它。 Reading kb s in a desktop is something which cannot be measured. 在桌面上读取kb是无法测量的。

The recommendation is usually to create a QSettings object when needed (in stack) and use it to read when needed. 建议通常是在需要时(在堆栈中)创建QSettings对象,并在需要时使用它来读取。 This is what I see in some Qt applications. 这是我在某些Qt应用程序中看到的。 The Qt documentation mentions this is light weight. Qt文档提到这很轻。 I usually maintain a global variable in my QMainWindow. 我通常在QMainWindow中维护一个全局变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM