Skip to content

Commit a195876

Browse files
author
SirJosh3917
committed
fixed documentation
1 parent 3e8d0e1 commit a195876

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

StringDB/Database.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ internal Database(Stream s, bool disposeStream = false) {
3636
internal void NotifyInsert(IEnumerable<KeyValuePair<string, string>> inserts) => (this._reader as Reader.Reader).NotifyInsert(inserts ?? throw new ArgumentNullException(nameof(inserts))); /// <inheritdoc/>
3737
internal void NotifyInsert(IEnumerable<IReaderPair> inserts) => (this._reader as Reader.Reader).NotifyInsert(inserts ?? throw new ArgumentNullException(nameof(inserts))); /// <inheritdoc/>
3838
IEnumerator IEnumerable.GetEnumerator() => this._reader.GetEnumerator();
39-
40-
/// <summary>Cleans out the DB. You should only use this if you've overwritten a value, or if you've done a lot of single inserts, or if you need to clean up a database</summary>
41-
/// <param name="dbCleanTo"></param>
39+
40+
/// <summary>Cleans out the database specified, and copies all of the contents of the other database into this one. You may be able to experience a smaller DB file if you've used StringDB to not to perfectionist values.</summary>
41+
/// <param name="dbCleanTo">The database to clean up</param>
4242
public void CleanFrom(Database dbCleanTo) {
4343
this.InsertRange(FromDatabase(dbCleanTo));
44+
}
45+
46+
/// <summary>Cleans out the current database, and copies all of the contents of this database into the other one. You may be able to experience a smaller DB file if you've used StringDB to not to perfectionist values.</summary>
47+
/// <param name="dbCleanTo">The database that will be used to insert the other database's values into</param>
48+
public void CleanTo(Database dbCleanTo) {
49+
dbCleanTo.InsertRange(FromDatabase(this));
4450
} /// <inheritdoc/>
4551

4652
public void Insert(string index, string value) {
@@ -79,9 +85,8 @@ public void Dispose() {
7985
}
8086

8187
private IEnumerable<IReaderPair> FromDatabase(Database other) {
82-
foreach (var i in other) {
88+
foreach (var i in other)
8389
yield return i;
84-
}
8590
}
8691
}
8792
}

StringDB/Writer/Writer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ public void InsertRange(IEnumerable<KeyValuePair<string, string>> items) {
7070
lock (this._lock) {
7171
#endif
7272
var l = this._stream.Length;
73-
74-
/*if (l >= 8)
75-
this._stream.Seek(0, SeekOrigin.End);
76-
else*/
73+
7774
if(l < 8) {
7875
_Seek(0);
7976
this._bw.Write((long)0);
@@ -88,8 +85,7 @@ public void InsertRange(IEnumerable<KeyValuePair<string, string>> items) {
8885
_Seek(p);
8986

9087
var judge = p + sizeof(byte) + sizeof(long);
91-
92-
//judge the amount of space it'd require to write each item
88+
9389
foreach (var i in items)
9490
judge += Judge_WriteIndex(i.Key);
9591

0 commit comments

Comments
 (0)