Skip to content

Commit 105e297

Browse files
author
Owen Jones
committed
Move dstringt documentation to above dstringt
1 parent 09c971c commit 105e297

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/util/README.md

+5-10
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@ See \ref irept for more information.
1616

1717
\subsection irep_idt_section Irep_idt and Dstringt
1818

19-
Inside `irept`s, strings are stored as `irep_idt`s, or `irep_namet`s for
20-
keys to `named_sub` or `comments`. If `USE_STD_STRING` is set then both
21-
`irep_idt` and `irep_namet` are `typedef`ed to `std::string`, but by default
22-
it is not set and they are `typedef`ed to `dstringt`. `dstringt` has one
23-
field, an unsigned integer which is an index into a static table of strings.
24-
This makes it expensive to create a new string (because you have to look
25-
through the whole table to see if it is already there, and add it if it
26-
isn't) but very cheap to compare strings (just compare the two integers). It
27-
also means that when you have lots of copies of the same string you only have
28-
to store the whole string once, which saves space.
19+
Inside \ref irept, strings are stored as irep_idts, or irep_namets for
20+
keys to named_sub or comments. By default both irep_idt and irep_namet
21+
are typedefed to \ref dstringt, unless USE_STD_STRING is set, in which
22+
case they are typedefed to std::string (this can be used for debugging
23+
purposes).
2924

3025
\dot
3126
digraph G {

src/util/dstring.h

+13-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@ Author: Daniel Kroening, [email protected]
1616

1717
#include "string_container.h"
1818

19-
// Marked final to disable inheritance.
20-
// No virtual destructor, so runtime-polymorphic use would be unsafe.
19+
/// `dstringt` has one field, an unsigned integer `no` which is an index into
20+
/// a static table of strings. This makes it expensive to create a new string
21+
/// (because you have to look through the whole table to see if it is already
22+
/// there, and add it if it isn't) but very cheap to compare strings (just
23+
/// compare the two integers). It also means that when you have lots of copies
24+
/// of the same string you only have to store the whole string once, which
25+
/// saves space.
26+
///
27+
/// `irep_idt` and `irep_namet` are typedef-ed to `dstringt` in irep.h unless
28+
///
29+
///
30+
/// Note: Marked final to disable inheritance. No virtual destructor, so
31+
/// runtime-polymorphic use would be unsafe.
2132
class dstringt final
2233
{
2334
public:

0 commit comments

Comments
 (0)