Merged
Conversation
Another way to remove exactly one file extension is:
introductionTemplatePath.string.changeFileExt("")
but it's not immediately obvious that only one file extension is
removed.
Just to be consistent with elsewhere in the configlet codebase:
$ git grep --heading --break 'for i[, ]' -- '*.nim'
src/helpers.nim
79: for i, c in s:
src/lint/track_config.nim
403: for i in 1..prereqPath.high:
src/patched_stdlib/json.nim
433: for i in 0 ..< x.len:
439: for i in 0 ..< x.len:
572: for i in 0..<L:
613: for i in index:
633: for i in 0..(keys.len-2):
666: for i in items(p.elems):
798: for i in 0..len(node.elems)-1:
842: for i in items(node.elems):
849: for i in mitems(node.elems):
1015: for i in 0 ..< x.len:
1176: for i in 0 ..< jsonNode.len:
1186: for i in 0 ..< jsonNode.len:
1304: for i in 1 ..< typeNode.len:
1309: for i in 0 ..< typeNode.len-1:
src/patched_stdlib/parsejson.nim
255: for i in 1 .. length:
src/sync/exercises.nim
69: for i, testCase in testCases:
src/sync/sync_common.nim
34: for i, item in e:
151: for i, item in val:
src/sync/sync_docs.nim
36: for i in countdown(result.high, descHeader.len):
38: for i, c in instrHeader:
src/sync/sync_filepaths.nim
29: for i, pattern in patterns:
src/uuid/uuid.nim
14: for i in 1 .. numUuidsToGenerate:
tests/test_fmt.nim
207: for i in 1..100:
282: for i in 1..100:
tests/test_lint.nim
74: for i, c in ValidUuidV4:
125: for i in HexIndices:
143: for i in HyphenIndices:
150: for i in HyphenIndices:
158: for i in HexIndices:
166: for i in HyphenIndices:
177: for i in 0 .. uuid.high:
tests/test_uuid.nim
8: for i in 1 .. 1000:
For the reader who isn't sure about what `substr` does when only two arguments are passed, this is clearer that we're removing the beginning of the string rather than the end. However, we'll change this line later in this PR to slice in place.
Allocate less, DRY slightly, and allow further refactoring in the next commits.
We now do an in-place `strip`, so let's do the same for slicing.
5 tasks
ErikSchierboom
approved these changes
Jun 17, 2022
4 tasks
The previous pattern of `result.add` without setting `result` may become
an error in a future version of Nim.
The initial size isn't particularly important, but here are the concept
introduction.md file sizes for Elixir:
$ wc -c $(git ls-files -- 'concepts/*/introduction.md')
1142 concepts/access-behaviour/introduction.md
890 concepts/agent/introduction.md
472 concepts/alias/introduction.md
1167 concepts/anonymous-functions/introduction.md
1542 concepts/ast/introduction.md
464 concepts/atoms/introduction.md
3477 concepts/basics/introduction.md
3078 concepts/behaviours/introduction.md
1983 concepts/binaries/introduction.md
393 concepts/bit-manipulation/introduction.md
1713 concepts/bitstrings/introduction.md
634 concepts/booleans/introduction.md
386 concepts/case/introduction.md
840 concepts/charlists/introduction.md
477 concepts/cond/introduction.md
947 concepts/dates-and-time/introduction.md
804 concepts/default-arguments/introduction.md
1041 concepts/docs/introduction.md
493 concepts/dynamic-dispatch/introduction.md
2473 concepts/enum/introduction.md
1782 concepts/erlang-libraries/introduction.md
654 concepts/errors/introduction.md
1802 concepts/exceptions/introduction.md
1161 concepts/file/introduction.md
1149 concepts/floating-point-numbers/introduction.md
7576 concepts/genserver/introduction.md
587 concepts/guards/introduction.md
1310 concepts/if/introduction.md
554 concepts/import/introduction.md
153 concepts/integers/introduction.md
1112 concepts/io/introduction.md
744 concepts/keyword-lists/introduction.md
1514 concepts/links/introduction.md
1000 concepts/list-comprehensions/introduction.md
1030 concepts/lists/introduction.md
1061 concepts/maps/introduction.md
553 concepts/module-attributes-as-constants/introduction.md
601 concepts/multiple-clause-functions/introduction.md
377 concepts/nil/introduction.md
1618 concepts/pattern-matching/introduction.md
278 concepts/pids/introduction.md
314 concepts/pipe-operator/introduction.md
2509 concepts/processes/introduction.md
654 concepts/protocols/introduction.md
345 concepts/randomness/introduction.md
375 concepts/ranges/introduction.md
526 concepts/recursion/introduction.md
3400 concepts/regular-expressions/introduction.md
807 concepts/streams/introduction.md
679 concepts/strings/introduction.md
1738 concepts/structs/introduction.md
1590 concepts/tail-call-recursion/introduction.md
1385 concepts/tasks/introduction.md
703 concepts/try-rescue-else-after/introduction.md
1431 concepts/try-rescue/introduction.md
1016 concepts/tuples/introduction.md
2125 concepts/typespecs/introduction.md
1483 concepts/use/introduction.md
852 concepts/with/introduction.md
72964 total
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Rename index variable to
iPrefer in-place
stripand sliceRemove an
elsebranchExplicitly initialize
result- the previous pattern ofresult.addbefore setting
resultmay become an error in a future version of NimDRY filename setting
Just splitting outsome tiny refactorings I did while working on the generate code.
I had some other refactorings here, but I'll leave them for later.