summary refs log tree commit diff stats
path: root/lib/pure
Commit message (Collapse)AuthorAgeFilesLines
* deques.nim: Refactor the `toDeque` functionality (#15166)ee72020-08-071-5/+18
| | | | | | | | | | | | | | | | | | | | This commit polishes the new proc introduced by d9ed816b10a6. Changes: - Rename to `toDeque` for more consistency with well-known procs like `toHashSet` and `toTable`. - Rename the `openArray` parameter. The name `arr` was potentially less clear given that the proc can be used with a seq (or string). - Add a `since` annotation. - Reword the doc comment, and clarify that ordering is preserved. - Add runnableExamples. - Add "see also" cross linking between `initDeque` and `toDeque`. - Remove duplicate `nextPowerOfTwo`. The `initImpl` template already includes it. - Implement the proc using the `items` iterator, rather than indexing. This matches the implementation of `sets.toHashSet` and `tables.toTable`. - Add a test within `when isMainModule`. - Add a changelog entry.
* Added the ability to initialize a deque with an openArray (#15138)archnim2020-08-051-0/+6
| | | | | | | | | | | | * Add ability to initialize a deque with a sequence Example: var dq = initDeque[char](@['a', 'b', 'c']) * Update deques.nim * Optimized deque initialization * Sequence replaced by open array in deque initialization
* fixes a collect() bug reported on the forum (#15156) [backport:1.2]Andreas Rumpf2020-08-041-0/+10
|
* minor improvement (#15155)flywind2020-08-041-1/+1
|
* Remove `noSideEffect` pragmas (#15143)sschwarzer2020-08-012-2/+2
| | | | | | These don't seem to make sense for the purpose of the procs and lead to errors when the `--experimental:strictFuncs` feature is enabled. See also https://github.com/nim-lang/Nim/issues/15142
* net: allow close() to ignore SSL failures due to disconnections (#15120)alaviss2020-08-011-8/+98
| | | | | | | | | | | | | | * net: allow close() to ignore SSL failures due to disconnections Comes with this PR is also a SIGPIPE handling contraption. * net: don't do selectSigpipe() on macOS macOS sockets have SO_NOSIGPIPE set, so an EPIPE doesn't necessary mean that a SIGPIPE happened. * net: fix alreadyBlocked logic * net: WSAESHUTDOWN is also a disconnection error
* export asyncdispatch handles (#15140)flywind2020-08-011-1/+1
| | | | | | | * improve epoll docs * export handles * add comments and changelog
* Revert "Small typo (#15132)" (#15134)Andreas Rumpf2020-07-311-1/+1
| | | This reverts commit 4bf8d38248f40cc0bf5323843a9ea38c5bcc20a8.
* Small typo (#15132)Oliver Daniel2020-07-311-1/+1
| | | The expected output necessarily cannot match the formatted string.
* Fix tables.CountTable largest and smallest (#15115)treeform2020-07-291-4/+4
| | | It needs to have len defined first because of the assert .len > 0. I just moved it up a bit to make them work.
* asyncnet, net: don't attempt SSL_shutdown if a fatal error occurred (#15066)alaviss2020-07-302-34/+52
| | | | | | | | | | | | | | | | | | | | | | | | | * asyncnet, net: don't attempt SSL_shutdown if a fatal error occurred Per TLS standard and SSL_shutdown(3ssl). This should prevent errors coming from a close() after a bad event (ie. the other end of the pipe is closed before shutdown can be negotiated). Ref #9867 * tssl: try sending until an error occur * tssl: cleanup * tssl: actually run the test I forgot to make the test run :P * tssl: run the test on ARC, maybe then it'll be happy * tssl: turns off ARC, switch tlsEmulation on for freebsd * tssl: document why tlsEmulation is employed * net: move SafeDisconn handling logic to socketError
* fixes #14139 (#15107)flywind2020-07-291-3/+3
| | | | | | | * fix #14139 * Update lib/pure/collections/heapqueue.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: Clyybber <darkmine956@gmail.com>
* Attempt to explain better why delImplIdx is the way it is. Maybe this can ↵c-blake2020-07-291-0/+30
| | | | | | | (#15108) avoid future implementation mischief. (Maybe not. Sometimes, general distrust of theory leads people to distrust simple reasoning over times from CPUs trying as hard as possible to mask DRAM latency via pre-fetch.)
* Fulfill https://github.com/nim-lang/Nim/pull/14995#issuecomment-664914391 ↵c-blake2020-07-283-42/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#15104) request. This can be conceived as an alternate, more capable resolution of https://github.com/nim-lang/Nim/issues/12200 than https://github.com/nim-lang/Nim/pull/12208 The code re-org idea here is to upgrade tablimpl.nim:`delImpl`/`delImplIdx` to abstract client code conventions for cell emptiness & cell hashing via three new template arguments - `makeEmpty`, `cellEmpty`, `cellHash` which all take a single integer argument and clear a cell, test if clear or produce the hash of the key stored at that index in `.data[]`. Then we update the 3 call sites (`Table`, `CountTable`, `SharedTable`) of `delImpl`/`delImplIdx` by defining define those arguments just before the first invocation as non-exported templates. Because `CountTable` does not save hash() outputs as `.hcode`, it needs a new tableimpl.nim:`delImplNoHCode` which simply in-lines the hash search when no `.hcode` field is available for "prefix compare" acceleration. It is conceivable this new template could be used by future variants, such as one optimized for integer keys where `hash()` and `==` are fast and `.hcode` is both wasted space & time (though a small change to interfaces there for a sentinel key meaning "empty" is needed for maximum efficiency). We also eliminate the old O(n) `proc remove(CountTable...)` in favor of simply invoking the new `delImpl*` templates and take care to correctly handle the case where `val` is either zero for non-existent keys in `inc` or evolves to zero over time in `[]=` or `inc`. The only user-visible changes from the +-42 delta here are speed, iteration order post deletes, and relaxing the `Positive` constraint on `val` in `proc inc` again, as indicated in the `changelog.md` entry.
* Fix #11352 strutil.insertSep() fails on negative numbers (#15087)Bung2020-07-281-6/+17
| | | | | | | | | | | | | | | | | | | * fix #11352 strutil.insertSep handle negtive number * test for #11352 * optimize * not parts string var * Update lib/pure/strutils.nim Thanks! Co-authored-by: alaviss <leorize+oss@disroot.org> * need to be countdown Co-authored-by: alaviss <leorize+oss@disroot.org>
* deprecate tables.allValues; continuation of #15047 (#15092)Miran2020-07-281-1/+2
|
* parsecsv: fix '\0' being displayed as '0' in docs (#15086) [backport]Jjp1372020-07-271-2/+2
|
* deprecate tables.add (#15047)Miran2020-07-251-4/+8
|
* json.nim: smaller init size (#15048)Miran2020-07-231-2/+2
| | | | There was a recent `rightSize` change in tables.nim, so the existing value (4) was creating too large tables.
* enforce browsers.nim only handles URLs [backport] (#15045)Andreas Rumpf2020-07-231-4/+10
|
* fix #15033 (#15034)Hugo Granström2020-07-221-1/+1
|
* smtp: Fix STARTTLS, request HELO once TLS is established (#15032)Mildred Ki'Lya2020-07-221-3/+9
|
* fix several newline problems (#15028) [backend]Miran2020-07-213-2/+37
| | | | * prevent newlines where they shouldn't be * 'contentLength' shouldn't be negative
* [Backport] Fixes callbacks being dropped on Linux/macOS/BSD. (#15012)Dominik Picheta2020-07-191-1/+6
| | | | | | | | | Fixes #15003. This is a serious bug which occurs when data cannot be read/sent immediately and there are a bunch of other read/write events pending. What happens is that the new events are dropped which results in the case of the reported bug resulted in some data not being sent (!).
* threadpool.nim: minor code style changesAraq2020-07-181-5/+5
|
* fix docs for nativesocket read/write selects (#15010)Andy Davidoff2020-07-181-2/+2
| | | The sockets which *cannot* be _[read from or written to]_ will also be removed from ``readfds``.
* Fix #14906 (#14949)Tomohiro2020-07-182-7/+181
| | | | | | | | | | | | | | | | | | | | | | | * Fix #14906 by wrapping outputStream with PipeOutStream * Fix compile error when ./build_all.sh * Use PipeOutStream on posix * Fix compile error when build_all.sh * Use ptr UncheckedArray * Replace copyRefObj * Remove tmp buffer from posPeekData * Add more tests for outputStream * Add comments about PipeOutStream.buffer * Fix bug in posReadLine * Move implementation of newPipeOutStream to streamwrapper module
* fix #14082, don't crash on incorrectly formatted input (#14977) [backport]Miran2020-07-173-42/+42
| | | | | | | * fix #14082, don't crash on incorrectly formatted input * address code review * remove duplication
* Fix #14994 (#14996)Clyybber2020-07-151-1/+2
| | | | | | | * Fix #14994 * Revert misplaced "optimization" * Typo
* fix #13086 (#14987)flywind2020-07-151-2/+2
| | | | | | | | | | | | | | | | | * fix #6608 * minor * fix * clean tests * make testamnet happy * again * minor * fix #13086
* Clean up macros (#14959)Juan Carlos2020-07-141-1/+1
|
* fix index error (#14974)Hendrik2020-07-141-1/+2
| | | Co-authored-by: Hendrik Albers <mail@hendrik.dev>
* fix #14475; unittest.require now works with `nim c`; require and check now ↵Timothee Cour2020-07-141-7/+6
| | | | | | | | | | | | | works with -d:nodejs (#14676) * fix #14475; make unittest work with -d:nodejs * fixup * fixup * disable inim, delaunay which failed after unittest.require got fixed * re-enable tests that have been fixed
* asyncftpclient.nim - don't assume a sufficiend line length (#14973)Miran2020-07-141-1/+1
|
* Fix #12759 (#14967)flywind2020-07-121-1/+1
| | | | | * add testcase for #5926 * fix #12759
* add docs and more tests for debug format strings (#14861)flywind2020-07-081-1/+46
| | | | | | | | | | | | | | | | | * add debug format string * remove try except * add changelog * add docs and more tests * Update lib/pure/strformat.nim Co-authored-by: Juan Carlos <juancarlospaco@gmail.com> * minor Co-authored-by: Juan Carlos <juancarlospaco@gmail.com>
* remove a condition that table size must be passed as power of 2 (#14926)Miran2020-07-087-92/+29
| | | | | | | | | | | | | | | * remove a condition that table size must be passed as power of 2 * remove power-of-2 condition from sets and sharedtables * remove power-of-2 condition from deques * use 'correctSize' for both branches * prettify changelog.md and fix typos * add a changelog entry * fix double-call of 'right-size' * fix the same thing in sets.nim * introduce a new internal proc `slotsNeeded` Deprecate the public proc `rightSize`, which is not needed anymore. Now it is an identity function, allowing the old code to work correctly and without extra allocations.
* fixes #14402 (#14908)Andreas Rumpf2020-07-081-1/+1
| | | | | * fixes #14402 * added a test case
* fix mistake in times.nim docsnarimiran2020-07-071-1/+1
|
* Revert commit 3e843ab3358. Closes #14930.Dominik Picheta2020-07-071-1/+1
|
* tables.nim: Add named fields in `smallest` and `largest` (#14919)ee72020-07-061-2/+2
| | | | | | | | | | The `smallest` and `largest` procs for `CountTable` returned a tuple with named fields, but the same procs for `CountTableRef` returned an anonymous tuple. This commit makes those `CountTableRef` procs more consistent, and adds a test. Fixes: #14918
* Fix style inconsistencies due to the previous commitnarimiran2020-07-064-67/+67
|
* revert 0944b0f4narimiran2020-07-064-67/+67
|
* Fix logging tiny bug (#14910)Juan Carlos2020-07-061-3/+7
| | | | | | | | | | | | | | | | | | | * Fix logging tiny bug * Update changelog.md Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com> * Update changelog.md Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com> * Update changelog.md Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com> * https://github.com/nim-lang/Nim/pull/14910#discussion_r450012032 Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com>
* deprecate existsDir; use dirExists instead (#14884)Timothee Cour2020-07-032-18/+12
|
* {.deprecated: [existsFile: fileExists].} (#14735)Timothee Cour2020-07-024-21/+20
| | | | | | | | | * {.deprecated: [existsFile: fileExists].} * s/existsFile/fileExists/ except under deps * workaround pending #14819 * fix test
* Clean out sharedlists (#14857)Juan Carlos2020-07-021-6/+0
|
* Clean out strutils (#14859)Juan Carlos2020-07-011-5/+0
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fix #14846; add macros.extractDocCommentsAndRunnables (#14849)Timothee Cour2020-07-011-3/+3
| | | | | | | | | * fix #14846; add macros.extractDocCommentsAndRunnables * fixup * update tests * address comment
* Clean out sharedtables (#14858)Juan Carlos2020-06-301-10/+0
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>