Commit Graph

1013 Commits

Author SHA1 Message Date
Kurtis Rader
704517e237 Fix set --local when var is not in local scope
Fixes #4321
2017-08-19 21:39:21 -07:00
Kurtis Rader
335f397277 Actually flip the order of the interpolated values
The previous commit was a no-op. Fix it.
2017-08-19 20:22:53 -07:00
Kurtis Rader
e9b24327d0 Make argparse error message deterministic
Recent changes to switch to unordered sets/maps can cause the order in
which items are returned to be non-deterministic. This change ensures
that the argparse "Mutually exclusive flags" error message to be
deterministic with respect to the order of the interpolated values.
2017-08-19 20:09:44 -07:00
Kurtis Rader
11400fb313 Another fish var performance improvement
Make setting fish vars more efficient by avoiding creating a
wcstring_list_t for the case where we're setting one value. For the case
where we're passing a list of values swap it with the list in the var
rather than copying it. This makes the benchmark in #4200 approximately
6% faster.
2017-08-19 20:01:06 -07:00
Mahmoud Al-Qudsi
a77cd98136 Removed XXHash and converted some wchar_t* to wcstring 2017-08-19 18:27:24 -05:00
Mahmoud Al-Qudsi
d54fbddb11 Using XXHash64 for all wcstring unordered_map/set hashing
Since we are including XXHash32/64 anyway for the wchar_t* hashing,
we might as well use it.

Use arch-specific hash size and xxhash for all wcstring hashing

Instead of using XXHash64 for all platforms, use the 32-bit version
when running on 32-bit platforms where XXHash64 is significantly slower
than XXHash32 (and the additional precision will not be used).

Additionally, manually specify wcstring_hash as hashing method for
non-const wcstring unordered_set/map instances (the const varieties
don't have an in-library hash and so already use our xxhash-based
specialization when calling std::hash<const wcstring>).
2017-08-19 15:36:45 -05:00
Mahmoud Al-Qudsi
d9f901f36d Squashed commit of the following:
commit 50f414a45d58fcab664ff662dd27befcfa0fdd95
Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date:   Sat Aug 19 13:43:35 2017 -0500

    Converted file_id_t set to unordered_set with custom hash

commit 83ef2dd7cc1bc3e4fdf0b2d3546d6811326cc3c9
Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date:   Sat Aug 19 13:43:14 2017 -0500

    Converted remaining set<wcstring> to unordered_set<wcstring>

commit 053da88f933f27505b3cf4810402e2a2be070203
Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date:   Sat Aug 19 13:29:21 2017 -0500

    Switched function sets to unordered_set

commit d469742a14ac99599022a9258cda8255178826b5
Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date:   Sat Aug 19 13:21:32 2017 -0500

    Converted list of modified variables to an unordered set

commit 5c06f866beeafb23878b1a932c7cd2558412c283
Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date:   Sat Aug 19 13:15:20 2017 -0500

    Convert const_string_set_t to std::unordered_set

    As it is a readonly-list of raw character pointer strings (not
    wcstring), this necessitated the addition of a hashing function since
    the C++ standard library does not come with a char pointer hash
    function.

    To that end, a zlib-licensed [0] port of the excellent, lightweight
    XXHash family of 32- and 64-bit hashing algorithms in the form of a C++
    header-only include library has been included. XXHash32/64 is pretty
    much universally the fastest hashing library for general purpose
    applications, and has been thoroughly vetted and is used in countless
    open source projects. The single-header version of this library makes it
    a lot simpler to include in the fish project, and the license
    compatibility with fish' GPLv2 and the zero-lib nature should make it an
    easy decision.

    std::unordered_set brings a massive speedup as compared to the default
    std::set, and the further use of the fast XXHash library to provide the
    string hashing should make all forms of string lookups in fish
    significantly faster (to a user-noticeable extent).

    0: http://create.stephan-brumme.com/about.html

commit 30d7710be8f0c23a4d42f7e713fcb7850f99036e
Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date:   Sat Aug 19 12:29:39 2017 -0500

    Using std::unordered_set for completions backing store

    While the completions shown to the user are sorted, their storage in
    memory does not need to be since they are re-sorted before they are
    shown in completions.cpp.

commit 695e83331d7a60ba188e57f6ea0d9b6da54860c6
Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date:   Sat Aug 19 12:06:53 2017 -0500

    Updated is_loading to use unordered_set
2017-08-19 15:36:45 -05:00
Mahmoud Al-Qudsi
61b4900a70 Switch from std::map<> to std::unordered_map<> where possible
Didn't switch env_var_t map because it seems to be mostly iterated in
order, but that decision may be revisited at a later date.
2017-08-19 11:55:06 -05:00
David Adam
0dce9a2114 autoload: drop unused is_internalized property 2017-08-19 22:46:51 +08:00
Mahmoud Al-Qudsi
e76c1fd139 Remove custom lock types in favor of native C++11 mutexes
No longer using RAII wrappers around pthread_mutex_t and pthread_cond_t
in favor of the C++11 std::mutex, std::recursive_mutex, and
std::condition_variable data types.
2017-08-18 23:09:31 -05:00
Kurtis Rader
b1ac07a178 Reduce overhead of setting fish vars
The `react_to_variable_change()` function is called whenever a fish var
is set. Even as a consequence of statements like `for x in a b c`. It is
therefore critical that that function be as fast as possible. Especially
when setting the var doesn't have any side-effects which is true something
like 99.9999% of the time.

This change reduces the overhead of `react_to_variable_change()` to
unmeasurable levels. Making the synthetic benchmark in issue #4341
36% faster.

Fixes #4341
2017-08-18 20:13:13 -07:00
Kurtis Rader
55b2d36028 Remove unused vars identified by lint 2017-08-18 16:52:39 -07:00
Kurtis Rader
f872f25f5b change env_var_t to a vector of strings
Internally fish should store vars as a vector of elements. The current
flat string representation is a holdover from when the code was written
in C.

Fixes #4200
2017-08-18 16:24:30 -07:00
Kurtis Rader
ea45541d53 fix set --show of semi-empty var
A semi-empty var is one with a single empty string element. The
`env_var_t::empty()` method returns true for such vars but we want
`set --show` to report that it has a single empty element.
2017-08-16 13:39:48 -07:00
Mahmoud Al-Qudsi
e6bb7fc973 Silence unused result warnings on newer compilers
Newer versions of GCC and Clang are not satisfied by a cast to void,
this fix is adapted from glibc's solution.

New wrapper function ignore_result should be used when a function with
explicit _unused_attribute_ wrapper is called whose result will not be
handled.
2017-08-14 18:18:10 -07:00
Kurtis Rader
42ddab0cb4 make missing_var a singleton
Make the `env_var_t::missing_var()` object a singleton rather than a
dynamically constructed object. This requires some discipline in its use
since C++ doesn't directly support immutable objects. But it is slightly
more efficient and helps identify code that incorrectly mutates `env_var_t`
objects that should not be modified.
2017-08-14 18:18:10 -07:00
Kurtis Rader
58b604c5ba change order of env_set() args
It's bugged me forever that the scope is the second arg to `env_get()`
but not `env_set()`. And since I'll be introducing some helper functions
that wrap `env_set()` now is a good time to change the order of its
arguments.
2017-08-14 18:18:09 -07:00
peoro
5ceac038b1 Improved warning message when exiting with jobs still active
Fixes #4303
2017-08-14 18:18:09 -07:00
Kurtis Rader
74f0be2a53 remove more ENV_NULL references 2017-08-14 18:18:09 -07:00
Kurtis Rader
82b5ba1af4 fix bug in env_get() involving empty vars
My previous change to eliminate `class var_entry_t` caused me to notice
that `env_get()` turned a set but empty var into a missing var. Which
is wrong. Fixing that brought to light several other pieces of code that
were wrong as a consequence of the aforementioned bug.

Another step to fixing issue #4200.
2017-08-14 18:18:09 -07:00
Kurtis Rader
728a4634a1 replace var_entry_t with env_var_t
This is a step to storing fish vars as actual vectors rather than flat
strings.
2017-08-14 18:18:09 -07:00
Fabian Homborg
745a88f2f6 Revert "Fix clearing abandoned line with VTE (#4243)"
Unfortunately, this breaks the expect tests.

So, until I can figure out how to unbreak them:

This reverts commit 09cb31a172.
2017-08-14 18:17:34 -07:00
Fabian Homborg
cf00162340 Fix clearing abandoned line with VTE (#4243)
* Fix clearing abandoned line with VTE

With VTE-based terminals, resizing currently causes multi-line prompts
to go weird.

This changes the sequence we use to clear the line to one suggested by
a VTE
developer (https://bugzilla.gnome.org/show_bug.cgi?id=763390#c4).

It changes nothing in konsole 17.04.3 and urxvt 9.22, but they already
work.

Note that this does not fix the case where output did not end in a
newline, but that doesn't seem to be up to us. Also, it only affects
those lines.

Fixes #2320.

* Use terminfo definition instead of hardcoding

Thanks to @ixjlyons.
2017-08-14 18:17:34 -07:00
Kurtis Rader
a40d5d4ea6 fix botched merge 2017-08-09 12:30:33 -07:00
Kurtis Rader
29f933adfc Merge branch 'master' into major 2017-08-09 12:26:24 -07:00
David Adam
5d2a806ac6 set: update language of warning message 2017-08-09 14:23:00 +08:00
Kurtis Rader
55bef3cd2e remove deprecated . (dot) command
Fixes #4294
2017-08-07 18:31:20 -07:00
Kurtis Rader
fb7645659f Merge branch 'master' into major 2017-08-06 20:22:31 -07:00
Kurtis Rader
4f5bd08b20 improve set -U warning
Doing `set -U var` when a global named `var` exists can result in
confusing behavior. Try to limit the confusion by improving the warning
we write. Also, only write the warning if interactive.

Fixes #4267
2017-08-06 19:57:25 -07:00
Kurtis Rader
975a5bfbde make style-all time again
Recent changes have introduced some style deviations so clean them up.
2017-08-06 16:05:51 -07:00
Kurtis Rader
acdb81bbca lint and style cleanups 2017-08-06 15:47:01 -07:00
Kurtis Rader
083224d1c0 fixes to job control changes
The job control changes need a couple of fixes for compatibility with
changes I merged while @mqudsi was workin on his change.
2017-08-06 15:25:42 -07:00
Kurtis Rader
52d739c746 Revert "Revert "finish cleanup of signal blocking code""
This reverts commit 35ee28ff24.

Reapply the signal blocking cleanup change on top of the job control
changes made by @mqudsi.
2017-08-06 14:46:12 -07:00
Mahmoud Al-Qudsi
0594735714 Deduplication between INTERNAL_FUNCTION and INTERNAL_BLOCK_NODE 2017-08-06 14:41:27 -07:00
Mahmoud Al-Qudsi
4dfb334db8 Corrected job_type for external command in debug log 2017-08-06 14:41:27 -07:00
Mahmoud Al-Qudsi
384879704a Unified all child/parent forking code in exec_job 2017-08-06 14:41:27 -07:00
Mahmoud Al-Qudsi
4a1de248bc Split internal_exec to its own function 2017-08-06 14:41:27 -07:00
Mahmoud Al-Qudsi
711c81b8c8 Raised debug level for "Retrying setpgid" message 2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
87db424e45 Removed unused <mutex> header include 2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
7e23965250 Cleaned up terminal_give_to_job() code flow and comments
No longer using a lambda for pgroupTerminated, using a boolean flag
instead. The new code structure should be much more self-documenting.
2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
dabe718c52 Removed unused job_t * parameter from setup_child_process 2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
628db65504 OS X EINVAL compatibility for waitpid
The return value on OS X is more along the lines of the documented
waitpid behavior; EINVAL is returned if the group no longer exists.
2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
8e63386203 Removed old/unneeded variants of block_child 2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
16d2f4faff Added important comment about blocked_pid 2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
15da6f0203 Minor refactoring 2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
a0efae5f08 Logging updates 2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
5db8065f15 unblock_previous on exec_job finish 2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
c3d756b5df blocking only if pipes_to_next_command breaks things like read.expect test 2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
b27217e106 terminal_give_to_job() was bypassing the cont branch
If tcgetpgrp for STDIN was already a match, the `cont` branch was
skipped. This wais making the history.expect test fail.
2017-08-06 14:40:18 -07:00
Mahmoud Al-Qudsi
f7b051905e Split child_set_group from setup_child_process
setup_child_process blocks in the case of IO_FILE, meaning it can't
be called before child processes SIGSTOP.
2017-08-06 14:40:18 -07:00